|  | @@ -37,21 +37,21 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  					'mold' => 'ordinary' 
 | 
	
		
			
				|  |  |  			) );
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  | -			//删除审批人后-加入权限问题-暂时关闭
 | 
	
		
			
				|  |  | +			// 删除审批人后-加入权限问题-暂时关闭
 | 
	
		
			
				|  |  |  			$fileInvoice = file_get_contents ( "protected/config/invoice/invoice.ini" );
 | 
	
		
			
				|  |  | -			$fiML=json_decode($fileInvoice,true);
 | 
	
		
			
				|  |  | -			if (empty($fiML))
 | 
	
		
			
				|  |  | -				$fiML=array();
 | 
	
		
			
				|  |  | -			foreach ($fiML as $key=>$value){
 | 
	
		
			
				|  |  | -			$sidList=explode(',',$value);
 | 
	
		
			
				|  |  | -			foreach ($sidList as $k=>$v){
 | 
	
		
			
				|  |  | -			if ($v==$sid){
 | 
	
		
			
				|  |  | -			array_push ( $moldList, array (
 | 
	
		
			
				|  |  | -			'mold' => $key
 | 
	
		
			
				|  |  | -			) );
 | 
	
		
			
				|  |  | -			break;
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | +			$fiML = json_decode ( $fileInvoice, true );
 | 
	
		
			
				|  |  | +			if (empty ( $fiML ))
 | 
	
		
			
				|  |  | +				$fiML = array ();
 | 
	
		
			
				|  |  | +			foreach ( $fiML as $key => $value ) {
 | 
	
		
			
				|  |  | +				$sidList = explode ( ',', $value );
 | 
	
		
			
				|  |  | +				foreach ( $sidList as $k => $v ) {
 | 
	
		
			
				|  |  | +					if ($v == $sid) {
 | 
	
		
			
				|  |  | +						array_push ( $moldList, array (
 | 
	
		
			
				|  |  | +								'mold' => $key 
 | 
	
		
			
				|  |  | +						) );
 | 
	
		
			
				|  |  | +						break;
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  |  			foreach ( $moldList as $value ) {
 | 
	
	
		
			
				|  | @@ -95,19 +95,48 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	function testSend() {
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		// $msTouser='caipin|outaozhen';
 | 
	
		
			
				|  |  | +		// 测试根据规则发送信息 普通发送
 | 
	
		
			
				|  |  | +		/*
 | 
	
		
			
				|  |  | +		 * $pendingApprovalsSid = 41; Doo::loadModel ( 'staff' ); $staff = new staff (); $username2 = $staff->getOne ( array ( 'select' => 'wxid', 'where' => 'sid=' . $pendingApprovalsSid, 'asArray' => TRUE ) ); // 发送微信审批通知 $title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。'; $this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
 | 
	
		
			
				|  |  | +		 */
 | 
	
		
			
				|  |  | +		Doo::loadModel ( 'staff' );
 | 
	
		
			
				|  |  | +		$staff = new staff ();
 | 
	
		
			
				|  |  | +		$toparty = $this->getToparty ( '广东办' );
 | 
	
		
			
				|  |  | +		$wxList = array ();
 | 
	
		
			
				|  |  | +		if (! empty ( $toparty )) {
 | 
	
		
			
				|  |  | +			$userList = $this->getUserByToparty ( $toparty );
 | 
	
		
			
				|  |  | +			$userCon = implode ( ',', $userList );
 | 
	
		
			
				|  |  | +			// echo $userCon;
 | 
	
		
			
				|  |  | +			$sidList = $staff->getStaffByWxid ( $userCon );
 | 
	
		
			
				|  |  | +			foreach ( $sidList as $key => $value ) {
 | 
	
		
			
				|  |  | +				$falg = $this->isSendNotification ( $value ['sid'], 'receivables' );
 | 
	
		
			
				|  |  | +				if ($falg) {
 | 
	
		
			
				|  |  | +					array_push ( $wxList, $value ['wxid'] );
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			$wxString = implode ( '|', $wxList );
 | 
	
		
			
				|  |  | +			print_r ( $wxList );
 | 
	
		
			
				|  |  | +			echo $wxString;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | +		// 测试发送
 | 
	
		
			
				|  |  | +		/*
 | 
	
		
			
				|  |  | +		 * //$toparty = $this->getWxidByCategory( $receivablesCategory [1] ); $toparty = $this->getToparty ( $receivablesCategory [1] ); $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。'; if ($toparty != 0) $this->msgSendToparty ( $msg, '', '', $toparty, 'text' );
 | 
	
		
			
				|  |  | +		 */
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		$toparty = $this->getToparty ( $receivablesCategory [1] );
 | 
	
		
			
				|  |  | -		$title2 = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
 | 
	
		
			
				|  |  | +		// print_r ( $userList );
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		// $msTouser='caipin|outaozhen';
 | 
	
		
			
				|  |  | +		// $toparty = $this->getToparty ( $receivablesCategory [1] );
 | 
	
		
			
				|  |  | +		// $title2 = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		//$hfreult = $this->msgSend ( '', $title2, '', 'outaozhen' );
 | 
	
		
			
				|  |  | +		// $hfreult = $this->msgSend ( '', $title2, '', 'outaozhen' );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		// $toparty= $this->getToparty('广东办');
 | 
	
		
			
				|  |  | -		//$msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
 | 
	
		
			
				|  |  | -		//$toparty = 26;
 | 
	
		
			
				|  |  | +		// $msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
 | 
	
		
			
				|  |  | +		// $toparty = 26;
 | 
	
		
			
				|  |  |  		// $msg = '';
 | 
	
		
			
				|  |  | -		 //$url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/1.html';
 | 
	
		
			
				|  |  | +		// $url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/1.html';
 | 
	
		
			
				|  |  |  		// $hfreult = $this->msgSendToparty ( $msg, '', '', $toparty,'text' );
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	function invoice() {
 | 
	
	
		
			
				|  | @@ -126,8 +155,6 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		$isMonth = $invoiceStatistics->getStatisticsByMonth ();
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  |  		$year = date ( "Y" );
 | 
	
		
			
				|  |  |  		$tmp_date = date ( "Ym" );
 | 
	
		
			
				|  |  |  		$tmp_year = substr ( $tmp_date, 0, 4 );
 | 
	
	
		
			
				|  | @@ -280,7 +307,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  					$moldManage [$value ['mold']] = $value ['staffList'];
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  | -			$pendingApprovalsSid=current ( $invoiceManageDetail ['staffList'] ) [0];
 | 
	
		
			
				|  |  | +			$pendingApprovalsSid = current ( $invoiceManageDetail ['staffList'] ) [0];
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  |  			$item = array (
 | 
	
		
			
				|  |  |  					'cid' => $cid,
 | 
	
	
		
			
				|  | @@ -406,18 +433,17 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  |  			$invoiceOperationLog->setInvoiceOperationLog ( $item );
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  | -			
 | 
	
		
			
				|  |  |  			Doo::loadModel ( 'staff' );
 | 
	
		
			
				|  |  |  			$staff = new staff ();
 | 
	
		
			
				|  |  |  			$username2 = $staff->getOne ( array (
 | 
	
		
			
				|  |  |  					'select' => 'wxid',
 | 
	
		
			
				|  |  |  					'where' => 'sid=' . $pendingApprovalsSid,
 | 
	
		
			
				|  |  | -					'asArray' => TRUE
 | 
	
		
			
				|  |  | +					'asArray' => TRUE 
 | 
	
		
			
				|  |  |  			) );
 | 
	
		
			
				|  |  | -			//发送微信审批通知
 | 
	
		
			
				|  |  | +			// 发送微信审批通知
 | 
	
		
			
				|  |  |  			$title2 = '[通知]用户提交了一条开票申请,快到“我的发票”中查看,给用户确认审批。';
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  | -			$this->msgSend ( '', $title2, '', $username2 ['wxid'] );
 | 
	
		
			
				|  |  | +			$this->msgSend ( '', $title2, '', $username2 ['wxid'], $pendingApprovalsSid, 'approval' );
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		return "/invoice";
 | 
	
	
		
			
				|  | @@ -641,13 +667,14 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'invoiceTraining' );
 | 
	
		
			
				|  |  |  		$invoiceTraining = new invoiceTraining ();
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		$itList=$invoiceTraining->getInvoiceTrainingByStatus(0);
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | +		$itTodoList = $invoiceTraining->getInvoiceTrainingByTodo ();
 | 
	
		
			
				|  |  | +		$itedList = $invoiceTraining->getInvoiceTrainingByStatus ( 2 );
 | 
	
		
			
				|  |  |  		$category = $lCategory->getCategory ();
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		//print_r($itList);
 | 
	
		
			
				|  |  | +		// print_r($itList);
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		$this->data['itList']=$itList;
 | 
	
		
			
				|  |  | +		$this->data ['itTodoList'] = $itTodoList;
 | 
	
		
			
				|  |  | +		$this->data ['itedList'] = $itedList;
 | 
	
		
			
				|  |  |  		$this->data ['category'] = $category;
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		$this->data ['memu'] = "invoice";
 | 
	
	
		
			
				|  | @@ -660,7 +687,6 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  	 * 创建培训班
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	function invoiceTrainingAdd() {
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  |  		$cid = $this->get_args ( 'cid' ) && is_numeric ( $this->get_args ( 'cid' ) ) ? $this->get_args ( 'cid' ) : 0;
 | 
	
		
			
				|  |  |  		$trainName = $this->get_args ( 'trainName' ) ? $this->get_args ( 'trainName' ) : "";
 | 
	
		
			
				|  |  |  		$trainDate = $this->get_args ( 'trainDate' ) ? $this->get_args ( 'trainDate' ) : "";
 | 
	
	
		
			
				|  | @@ -668,7 +694,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		if (empty ( $this->staff [0] ))
 | 
	
		
			
				|  |  |  			die ( 'illegal request' );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		if (! empty ( $cid ) && ! empty ( $trainName ) && ! empty ( $trainDate ) ) {
 | 
	
		
			
				|  |  | +		if (! empty ( $cid ) && ! empty ( $trainName ) && ! empty ( $trainDate )) {
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  |  			Doo::loadModel ( 'invoiceTraining' );
 | 
	
		
			
				|  |  |  			$invoiceTraining = new invoiceTraining ();
 | 
	
	
		
			
				|  | @@ -687,41 +713,55 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  					'trainName' => $trainName,
 | 
	
		
			
				|  |  |  					'trainDate' => $trainDate,
 | 
	
		
			
				|  |  |  					
 | 
	
		
			
				|  |  | -					'creator' => $this->staff [0]['sid'],
 | 
	
		
			
				|  |  | -					'creatorDate' => date ( "Y-m-d H:i:s" )
 | 
	
		
			
				|  |  | +					'creator' => $this->staff [0] ['sid'],
 | 
	
		
			
				|  |  | +					'creatorDate' => date ( "Y-m-d H:i:s" ) 
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | -			$itid = $invoiceTraining->addInvoiceTraining( $item );
 | 
	
		
			
				|  |  | +			$itid = $invoiceTraining->addInvoiceTraining ( $item );
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  | -			//统计相关
 | 
	
		
			
				|  |  | +			// 统计相关
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  | -// 			$item = array (
 | 
	
		
			
				|  |  | -// 					'date' => date ( "Y-m-d H:i:s" ),
 | 
	
		
			
				|  |  | -// 					'operation' => "创建",
 | 
	
		
			
				|  |  | -// 					'status' => 1,
 | 
	
		
			
				|  |  | -// 					'img' => $this->staff [0] ['avatar'],
 | 
	
		
			
				|  |  | -// 					'username' => $this->staff [0] ['username'],
 | 
	
		
			
				|  |  | -// 					'uid' => $this->staff [0] ['sid'],
 | 
	
		
			
				|  |  | -// 					'category' => $this->staff [0] ['category'],
 | 
	
		
			
				|  |  | -// 					'iid' => $iid 
 | 
	
		
			
				|  |  | -// 			);
 | 
	
		
			
				|  |  | -// 			$invoiceOperationLog->setInvoiceOperationLog ( $item );
 | 
	
		
			
				|  |  | -// 			$item = array (
 | 
	
		
			
				|  |  | -// 					'date' => date ( "Y-m-d H:i:s" ),
 | 
	
		
			
				|  |  | -// 					'operation' => "提交审批",
 | 
	
		
			
				|  |  | -// 					'status' => 1,
 | 
	
		
			
				|  |  | -// 					'img' => $this->staff [0] ['avatar'],
 | 
	
		
			
				|  |  | -// 					'username' => $this->staff [0] ['username'],
 | 
	
		
			
				|  |  | -// 					'uid' => $this->staff [0] ['sid'],
 | 
	
		
			
				|  |  | -// 					'category' => $this->staff [0] ['category'],
 | 
	
		
			
				|  |  | -// 					'iid' => $iid 
 | 
	
		
			
				|  |  | -// 			);
 | 
	
		
			
				|  |  | -// 			$invoiceOperationLog->setInvoiceOperationLog ( $item );
 | 
	
		
			
				|  |  | +			// $item = array (
 | 
	
		
			
				|  |  | +			// 'date' => date ( "Y-m-d H:i:s" ),
 | 
	
		
			
				|  |  | +			// 'operation' => "创建",
 | 
	
		
			
				|  |  | +			// 'status' => 1,
 | 
	
		
			
				|  |  | +			// 'img' => $this->staff [0] ['avatar'],
 | 
	
		
			
				|  |  | +			// 'username' => $this->staff [0] ['username'],
 | 
	
		
			
				|  |  | +			// 'uid' => $this->staff [0] ['sid'],
 | 
	
		
			
				|  |  | +			// 'category' => $this->staff [0] ['category'],
 | 
	
		
			
				|  |  | +			// 'iid' => $iid
 | 
	
		
			
				|  |  | +			// );
 | 
	
		
			
				|  |  | +			// $invoiceOperationLog->setInvoiceOperationLog ( $item );
 | 
	
		
			
				|  |  | +			// $item = array (
 | 
	
		
			
				|  |  | +			// 'date' => date ( "Y-m-d H:i:s" ),
 | 
	
		
			
				|  |  | +			// 'operation' => "提交审批",
 | 
	
		
			
				|  |  | +			// 'status' => 1,
 | 
	
		
			
				|  |  | +			// 'img' => $this->staff [0] ['avatar'],
 | 
	
		
			
				|  |  | +			// 'username' => $this->staff [0] ['username'],
 | 
	
		
			
				|  |  | +			// 'uid' => $this->staff [0] ['sid'],
 | 
	
		
			
				|  |  | +			// 'category' => $this->staff [0] ['category'],
 | 
	
		
			
				|  |  | +			// 'iid' => $iid
 | 
	
		
			
				|  |  | +			// );
 | 
	
		
			
				|  |  | +			// $invoiceOperationLog->setInvoiceOperationLog ( $item );
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		return "/invoiceTraining";
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  | +	 * 删除培训班
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	function invoiceTrainingDelDo(){
 | 
	
		
			
				|  |  | +		$itid = $this->get_args ( 'trainingKey' ) ? $this->get_args ( 'trainingKey' ) : "";
 | 
	
		
			
				|  |  | +		if (!empty($itid)){
 | 
	
		
			
				|  |  | +			Doo::loadModel ( 'invoiceTraining' );
 | 
	
		
			
				|  |  | +			$invoiceTraining = new invoiceTraining ();
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return "/invoiceTraining";
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  |  	 * 终止开票
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  |  	function invoiceDroppedDo() {
 | 
	
	
		
			
				|  | @@ -1221,7 +1261,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  |  			$msg = '';
 | 
	
		
			
				|  |  |  			$url = 'http://m.cld.smartcost.com.cn/invoicePrintDetail/' . $XDeode->encode ( $invoicePrintDetail ['iid'] ) . '.html';
 | 
	
		
			
				|  |  | -			$hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'] );
 | 
	
		
			
				|  |  | +			$hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'], $invoicePrintDetail ['sid'], 'print' );
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  |  			return "/invoicePrint";
 | 
	
		
			
				|  |  |  		}
 | 
	
	
		
			
				|  | @@ -1299,7 +1339,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		$msg = $expCom [0] . ':' . $invoicePrintDetail ['expressNumber'] . '';
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		$url = 'https://m.kuaidi100.com/result.jsp?nu=' . $invoicePrintDetail ['expressNumber'];
 | 
	
		
			
				|  |  | -		$hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'] );
 | 
	
		
			
				|  |  | +		$hfreult = $this->msgSend ( $msg, $title2, $url, $username2 ['wxid'], $invoicePrintDetail ['sid'], 'print' );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		return '/invoicePost';
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -1436,7 +1476,6 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'invoiceStatistics' );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  |  		$iid = $invoice->authcode ( $untreadIidKey );
 | 
	
		
			
				|  |  |  		if (! empty ( $iid ) && ! is_numeric ( $iid ))
 | 
	
		
			
				|  |  |  			die ( 'illegal request' );
 | 
	
	
		
			
				|  | @@ -1488,7 +1527,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  				$invoiceReceivables->setInvoiceReceivablesByCondition ( $item );
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  |  				if (! empty ( $irDetails )) {
 | 
	
		
			
				|  |  | -					//扣除入账
 | 
	
		
			
				|  |  | +					// 扣除入账
 | 
	
		
			
				|  |  |  					$invoiceStatistics = new invoiceStatistics ();
 | 
	
		
			
				|  |  |  					$item = array (
 | 
	
		
			
				|  |  |  							'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
 | 
	
	
		
			
				|  | @@ -1498,23 +1537,18 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  							'accountPrice' => - $irDetails ['receivablesPrice'] 
 | 
	
		
			
				|  |  |  					);
 | 
	
		
			
				|  |  |  					$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 | 
	
		
			
				|  |  | -					//扣除收款
 | 
	
		
			
				|  |  | +					// 扣除收款
 | 
	
		
			
				|  |  |  					$invoiceStatistics = new invoiceStatistics ();
 | 
	
		
			
				|  |  |  					$item = array (
 | 
	
		
			
				|  |  |  							'date' => date ( 'Y-m-d', strtotime ( $irDetails ['receivablesDate'] ) ),
 | 
	
		
			
				|  |  |  							'priceClass' => 2,
 | 
	
		
			
				|  |  |  							'cid' => $invoiceDetails ['cid'],
 | 
	
		
			
				|  |  |  							'staff' => $invoiceDetails ['sid'],
 | 
	
		
			
				|  |  | -							'irid'=>$irDetails ['irid'],
 | 
	
		
			
				|  |  | -							'receivablesPrice' => - $irDetails ['receivablesPrice']
 | 
	
		
			
				|  |  | +							'irid' => $irDetails ['irid'],
 | 
	
		
			
				|  |  | +							'receivablesPrice' => - $irDetails ['receivablesPrice'] 
 | 
	
		
			
				|  |  |  					);
 | 
	
		
			
				|  |  |  					$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 | 
	
		
			
				|  |  | -					
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  | -				
 | 
	
		
			
				|  |  | -				
 | 
	
		
			
				|  |  | -				
 | 
	
		
			
				|  |  | -				
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -1561,16 +1595,14 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  					'untreadStatus' => 4,
 | 
	
		
			
				|  |  |  					// 关联发票号
 | 
	
		
			
				|  |  |  					'lossIid' => $invoiceDetail ['iid'] 
 | 
	
		
			
				|  |  | -			)
 | 
	
		
			
				|  |  | -			;
 | 
	
		
			
				|  |  | +			);
 | 
	
		
			
				|  |  |  			$invoice->setInvoiceByCondition ( $item );
 | 
	
		
			
				|  |  |  			// 更新原发票
 | 
	
		
			
				|  |  |  			$invoice = new invoice ();
 | 
	
		
			
				|  |  |  			$item = array (
 | 
	
		
			
				|  |  |  					'iid' => $invoiceDetail ['iid'],
 | 
	
		
			
				|  |  |  					'lossIid' => $iid 
 | 
	
		
			
				|  |  | -			)
 | 
	
		
			
				|  |  | -			;
 | 
	
		
			
				|  |  | +			);
 | 
	
		
			
				|  |  |  			$invoice->setInvoiceByCondition ( $item );
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  |  			// 操作日志
 | 
	
	
		
			
				|  | @@ -1610,7 +1642,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		$receivablesList = $invoiceReceivables->getInvoiceReceivablesByNew ( 4, $sql );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		// 获取未入账发票
 | 
	
		
			
				|  |  | -		$invoiceUnAccount = $invoice->getInvoiceByUnAccount ($invoiceTC);
 | 
	
		
			
				|  |  | +		$invoiceUnAccount = $invoice->getInvoiceByUnAccount ( $invoiceTC );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		$invoiceExistAccount = $invoice->getInvoiceByUnAccount ( '', true );
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -1780,13 +1812,13 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  |  			$invoiceOperationLog->setInvoiceOperationLog ( $item );
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  | -			//入账汇总
 | 
	
		
			
				|  |  | +			// 入账汇总
 | 
	
		
			
				|  |  |  			$invoiceStatistics = new invoiceStatistics ();
 | 
	
		
			
				|  |  | -// 			$list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
 | 
	
		
			
				|  |  | -// 			$accountPrice = 0;
 | 
	
		
			
				|  |  | -// 			foreach ( $list as $key => $value ) {
 | 
	
		
			
				|  |  | -// 				$accountPrice += $value ['receivablesPrice'];
 | 
	
		
			
				|  |  | -// 			}
 | 
	
		
			
				|  |  | +			// $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
 | 
	
		
			
				|  |  | +			// $accountPrice = 0;
 | 
	
		
			
				|  |  | +			// foreach ( $list as $key => $value ) {
 | 
	
		
			
				|  |  | +			// $accountPrice += $value ['receivablesPrice'];
 | 
	
		
			
				|  |  | +			// }
 | 
	
		
			
				|  |  |  			$item = array (
 | 
	
		
			
				|  |  |  					'date' => $receivablesDate,
 | 
	
		
			
				|  |  |  					'priceClass' => 3,
 | 
	
	
		
			
				|  | @@ -1896,6 +1928,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  | +			// $toparty = $this->getWxidByCategory( $receivablesCategory [1] );
 | 
	
		
			
				|  |  |  			$toparty = $this->getToparty ( $receivablesCategory [1] );
 | 
	
		
			
				|  |  |  			$msg = '[通知]财务录入了一笔待认领款项,快到“我的收款”中查看,确认是否是您的客户给您打款了。';
 | 
	
		
			
				|  |  |  			if ($toparty != 0)
 | 
	
	
		
			
				|  | @@ -2072,7 +2105,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  					'cid' => $this->staff [0] ['cid'],
 | 
	
		
			
				|  |  |  					'staff' => $this->staff [0] ['sid'] 
 | 
	
		
			
				|  |  |  			);
 | 
	
		
			
				|  |  | -			$invoiceStatistics->updateInvoiceStatisticsByIrid ( $item, $detail ['irid'],2 );
 | 
	
		
			
				|  |  | +			$invoiceStatistics->updateInvoiceStatisticsByIrid ( $item, $detail ['irid'], 2 );
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		return "/invoiceReceivablesClaim";
 | 
	
	
		
			
				|  | @@ -2183,18 +2216,18 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'invoiceStatistics' );
 | 
	
		
			
				|  |  |  		$invoiceStatistics = new invoiceStatistics ();
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -// 		$list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
 | 
	
		
			
				|  |  | -// 		$accountPrice = 0;
 | 
	
		
			
				|  |  | -// 		foreach ( $list as $key => $value ) {
 | 
	
		
			
				|  |  | -// 			$accountPrice += $value ['receivablesPrice'];
 | 
	
		
			
				|  |  | -// 		}
 | 
	
		
			
				|  |  | +		// $list = $invoiceReceivables->getInvoiceReceivablesInIridString ( $iridString );
 | 
	
		
			
				|  |  | +		// $accountPrice = 0;
 | 
	
		
			
				|  |  | +		// foreach ( $list as $key => $value ) {
 | 
	
		
			
				|  |  | +		// $accountPrice += $value ['receivablesPrice'];
 | 
	
		
			
				|  |  | +		// }
 | 
	
		
			
				|  |  |  		$item = array (
 | 
	
		
			
				|  |  | -				'date' => $detailM['receivablesDate'],
 | 
	
		
			
				|  |  | +				'date' => $detailM ['receivablesDate'],
 | 
	
		
			
				|  |  |  				'priceClass' => 3,
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  |  				'cid' => $detail ['cid'],
 | 
	
		
			
				|  |  |  				'staff' => $detail ['sid'],
 | 
	
		
			
				|  |  | -				'accountPrice' => $detailM['receivablesPrice'] 
 | 
	
		
			
				|  |  | +				'accountPrice' => $detailM ['receivablesPrice'] 
 | 
	
		
			
				|  |  |  		);
 | 
	
		
			
				|  |  |  		$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -2705,7 +2738,6 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		$invoiceROLog = new invoiceROLog ();
 | 
	
		
			
				|  |  |  		Doo::loadModel ( 'invoiceStatistics' );
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  |  		$irid = $invoice->authcode ( $unBundKey );
 | 
	
		
			
				|  |  |  		if (! empty ( $irid ) && ! is_numeric ( $irid ))
 | 
	
		
			
				|  |  |  			die ( 'illegal request' );
 | 
	
	
		
			
				|  | @@ -2753,8 +2785,8 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  				'priceClass' => 2,
 | 
	
		
			
				|  |  |  				'cid' => $invoiceDetails ['cid'],
 | 
	
		
			
				|  |  |  				'staff' => $invoiceDetails ['sid'],
 | 
	
		
			
				|  |  | -				'irid'=>$irDetails ['irid'],
 | 
	
		
			
				|  |  | -				'receivablesPrice' => - $irDetails ['receivablesPrice']
 | 
	
		
			
				|  |  | +				'irid' => $irDetails ['irid'],
 | 
	
		
			
				|  |  | +				'receivablesPrice' => - $irDetails ['receivablesPrice'] 
 | 
	
		
			
				|  |  |  		);
 | 
	
		
			
				|  |  |  		$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 | 
	
		
			
				|  |  |  		
 | 
	
	
		
			
				|  | @@ -2817,13 +2849,17 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		$D1 = '';
 | 
	
		
			
				|  |  |  		$D2 = '';
 | 
	
		
			
				|  |  |  		if (! empty ( $date )) {
 | 
	
		
			
				|  |  | -			$D1 = $dateArr [0];
 | 
	
		
			
				|  |  | -			$D2 = $dateArr [1];
 | 
	
		
			
				|  |  | +			$D1 = $dateArr [0] . " 00:00:00 ";
 | 
	
		
			
				|  |  | +			if (isset ( $dateArr [1] ))
 | 
	
		
			
				|  |  | +				$D2 = $dateArr [1] . " 23:59:59 ";
 | 
	
		
			
				|  |  | +			else
 | 
	
		
			
				|  |  | +				$D2 = $dateArr [0] . " 23:59:59 "; // date ( "Y-m-d" );
 | 
	
		
			
				|  |  | +					                                   // $D2 = $dateArr [1];
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		$con = ' status=2  ';
 | 
	
		
			
				|  |  |  		if (! empty ( $D1 ) && ! empty ( $D2 ))
 | 
	
		
			
				|  |  | -			$con .= ' and date BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
 | 
	
		
			
				|  |  | +			$con .= ' and printTime BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		if ($status == 'UNRECORD')
 | 
	
		
			
				|  |  |  			$con .= ' and printStatus=1 and untreadStatus=0';
 | 
	
	
		
			
				|  | @@ -2831,7 +2867,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  			$con .= ' and printStatus=1 and untreadStatus=3';
 | 
	
		
			
				|  |  |  		elseif ($status == 'BOUNCED')
 | 
	
		
			
				|  |  |  			$con .= ' and untreadStatus=2';
 | 
	
		
			
				|  |  | -		elseif($status == 'PARTRECORD')
 | 
	
		
			
				|  |  | +		elseif ($status == 'PARTRECORD')
 | 
	
		
			
				|  |  |  			$con .= ' and untreadStatus=0 and printStatus=1 and irid!=""';
 | 
	
		
			
				|  |  |  		elseif ($status == 'All') {
 | 
	
		
			
				|  |  |  			$con .= ' and ( untreadStatus=2 or untreadStatus=0 or untreadStatus=3 )';
 | 
	
	
		
			
				|  | @@ -2848,7 +2884,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		$limit = $pageinfo ['lower'] . ',' . $page_size;
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  |  		$list = $invoice->getInvoiceByUntreadStatusPage ( $limit, $con );
 | 
	
		
			
				|  |  | -		// print_r($list);
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  |  		// foreach ($list as $key=>$value){
 | 
	
		
			
				|  |  |  		// $list[$key]['rpSum']=0;
 | 
	
		
			
				|  |  |  		// if (!empty($value['irid']))
 | 
	
	
		
			
				|  | @@ -2888,18 +2924,22 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		$D1 = '';
 | 
	
		
			
				|  |  |  		$D2 = '';
 | 
	
		
			
				|  |  |  		if (! empty ( $date )) {
 | 
	
		
			
				|  |  | -			$D1 = $dateArr [0];
 | 
	
		
			
				|  |  | -			$D2 = $dateArr [1];
 | 
	
		
			
				|  |  | +			$D1 = $dateArr [0]; // ." 00:00:00 ";
 | 
	
		
			
				|  |  | +			if (isset ( $dateArr [1] ))
 | 
	
		
			
				|  |  | +				$D2 = $dateArr [1]; // ." 23:59:59 ";
 | 
	
		
			
				|  |  | +			else
 | 
	
		
			
				|  |  | +				$D2 = $dateArr [0]; // ." 23:59:59 ";//date ( "Y-m-d" );
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | -		$con = '1';
 | 
	
		
			
				|  |  | -		if (! empty ( $D1 ) && ! empty ( $D2 ))
 | 
	
		
			
				|  |  | -			$con .= ' and date BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		$descField = 'bindDate';
 | 
	
		
			
				|  |  | +		$descField = 'receivablesDate';
 | 
	
		
			
				|  |  |  		if ($timeType == 'CREATE')
 | 
	
		
			
				|  |  |  			$descField = 'date';
 | 
	
		
			
				|  |  |  		
 | 
	
		
			
				|  |  | +		$con = '1';
 | 
	
		
			
				|  |  | +		if (! empty ( $D1 ) && ! empty ( $D2 ))
 | 
	
		
			
				|  |  | +			$con .= ' and ' . $descField . ' BETWEEN "' . $D1 . '" AND "' . $D2 . '" ';
 | 
	
		
			
				|  |  | +			
 | 
	
		
			
				|  |  | +			// echo $con;
 | 
	
		
			
				|  |  |  		if ($status == 'Unclaimed')
 | 
	
		
			
				|  |  |  			$con .= ' and bindStatus=0';
 | 
	
		
			
				|  |  |  		elseif ($status == 'Credited')
 | 
	
	
		
			
				|  | @@ -3600,8 +3640,8 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  					';
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  |  			$irList = $invoiceReceivables->getInvoiceReceivablesInIridString ( $invoiceDetail ['irid'] );
 | 
	
		
			
				|  |  | -			if (empty($irList))
 | 
	
		
			
				|  |  | -				$irList [0] ['sumPrice']=0;
 | 
	
		
			
				|  |  | +			if (empty ( $irList ))
 | 
	
		
			
				|  |  | +				$irList [0] ['sumPrice'] = 0;
 | 
	
		
			
				|  |  |  			$balance = $invoiceDetail ['invoicePrice'] - $irList [0] ['sumPrice'];
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  |  			$priceString = '';
 | 
	
	
		
			
				|  | @@ -3846,7 +3886,6 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  			Doo::loadModel ( 'invoiceStatistics' );
 | 
	
		
			
				|  |  |  			Doo::loadModel ( 'invoiceOperationLog' );
 | 
	
		
			
				|  |  |  			
 | 
	
		
			
				|  |  | -			
 | 
	
		
			
				|  |  |  			echo DOO::conf ()->SITE_PATH . "upload/invoice/" . iconv ( "UTF-8", "GB2312", $path );
 | 
	
		
			
				|  |  |  			$exlArray = $this->_format_excel_to_array ( DOO::conf ()->SITE_PATH . "upload/invoice/" . $path );
 | 
	
		
			
				|  |  |  			// print_r ( $exlArray );
 | 
	
	
		
			
				|  | @@ -3885,7 +3924,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  |  				$invoice->printTime = $value ['date'];
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  | -				$invoice->ipSource=1;
 | 
	
		
			
				|  |  | +				$invoice->ipSource = 1;
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  |  				$invoice->printStatus = 1;
 | 
	
		
			
				|  |  |  				$invoice->status = 2;
 | 
	
	
		
			
				|  | @@ -3893,11 +3932,11 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  				$invoice->untreadStatus = 0;
 | 
	
		
			
				|  |  |  				$invoice->invoiceSerial = "#F" . date ( "Ymd" ) . mt_rand ( 1000, 9999 );
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  | -				$iid=$invoice->insert ();
 | 
	
		
			
				|  |  | +				$iid = $invoice->insert ();
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  |  				// 汇总
 | 
	
		
			
				|  |  |  				$invoiceStatistics = new invoiceStatistics ();
 | 
	
		
			
				|  |  | -				// 
 | 
	
		
			
				|  |  | +				//
 | 
	
		
			
				|  |  |  				$item = array (
 | 
	
		
			
				|  |  |  						'date' => $value ['date'],
 | 
	
		
			
				|  |  |  						'priceClass' => 1,
 | 
	
	
		
			
				|  | @@ -3910,13 +3949,13 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  				$invoiceOperationLog = new invoiceOperationLog ();
 | 
	
		
			
				|  |  |  				$item = array (
 | 
	
		
			
				|  |  |  						'date' => date ( "Y-m-d H:i:s" ),
 | 
	
		
			
				|  |  | -						'operation' => date ( "Y-m-d" )." 导入",
 | 
	
		
			
				|  |  | +						'operation' => date ( "Y-m-d" ) . " 导入",
 | 
	
		
			
				|  |  |  						'status' => 1,
 | 
	
		
			
				|  |  |  						'img' => $sDetail ['avatar'],
 | 
	
		
			
				|  |  |  						'username' => $sDetail ['username'],
 | 
	
		
			
				|  |  |  						'uid' => $sDetail ['sid'],
 | 
	
		
			
				|  |  |  						'category' => $sDetail ['category'],
 | 
	
		
			
				|  |  | -						'iid' => $iid
 | 
	
		
			
				|  |  | +						'iid' => $iid 
 | 
	
		
			
				|  |  |  				);
 | 
	
		
			
				|  |  |  				$invoiceOperationLog->setInvoiceOperationLog ( $item );
 | 
	
		
			
				|  |  |  			}
 | 
	
	
		
			
				|  | @@ -4001,7 +4040,7 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  						'priceClass' => 3,
 | 
	
		
			
				|  |  |  						'cid' => $sDetail ['cid'],
 | 
	
		
			
				|  |  |  						'staff' => $sDetail ['sid'],
 | 
	
		
			
				|  |  | -						//'irid' => $irid,
 | 
	
		
			
				|  |  | +						// 'irid' => $irid,
 | 
	
		
			
				|  |  |  						'accountPrice' => $value ['receivablesPrice'] 
 | 
	
		
			
				|  |  |  				);
 | 
	
		
			
				|  |  |  				$invoiceStatistics->setInvoiceStatisticsByCondition ( $item );
 | 
	
	
		
			
				|  | @@ -4433,6 +4472,11 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获取微信部门
 | 
	
		
			
				|  |  | +	 * @param string $category
 | 
	
		
			
				|  |  | +	 * @return number|mixed
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  |  	function getToparty($category = '') {
 | 
	
		
			
				|  |  |  		$token = $this->getAccessToken (); //
 | 
	
		
			
				|  |  |  		$result = json_decode ( $this->httpGet ( "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token={$token}&id=5" ), true );
 | 
	
	
		
			
				|  | @@ -4443,6 +4487,22 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		return $toparty;
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获得某部门下的用户
 | 
	
		
			
				|  |  | +	 * @param string $toparty
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	function getUserByToparty($toparty = '') {
 | 
	
		
			
				|  |  | +		$token = $this->getAccessToken (); //
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$result = json_decode ( $this->httpGet ( "https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?access_token={$token}&department_id={$toparty}" ), true );
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$userList = array ();
 | 
	
		
			
				|  |  | +		foreach ( $result ['userlist'] as $key => $value ) {
 | 
	
		
			
				|  |  | +			array_push ( $userList, "'" . $value ['userid'] . "'" );
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return $userList;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  |  	function msgSendToparty($msg, $title, $url, $toparty, $text = '') {
 | 
	
		
			
				|  |  |  		$token = $this->getAccessToken ();
 | 
	
		
			
				|  |  |  		if ($text == 'text') {
 | 
	
	
		
			
				|  | @@ -4465,22 +4525,98 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |  			return 1;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	private function msgSend($msg, $title, $url, $user, $text = '') {
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 获得可以发送微信用户列表
 | 
	
		
			
				|  |  | +	 * @param string $category
 | 
	
		
			
				|  |  | +	 * @return string
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	function getWxidByCategory($category = "") {
 | 
	
		
			
				|  |  | +		if (empty ( $category ))
 | 
	
		
			
				|  |  | +			return "";
 | 
	
		
			
				|  |  | +		Doo::loadModel ( 'staff' );
 | 
	
		
			
				|  |  | +		$staff = new staff ();
 | 
	
		
			
				|  |  | +		$toparty = $this->getToparty ( $category );
 | 
	
		
			
				|  |  | +		$wxList = array ();
 | 
	
		
			
				|  |  | +		$wxString = "";
 | 
	
		
			
				|  |  | +		if (! empty ( $toparty )) {
 | 
	
		
			
				|  |  | +			$userList = $this->getUserByToparty ( $toparty );
 | 
	
		
			
				|  |  | +			$userCon = implode ( ',', $userList );
 | 
	
		
			
				|  |  | +			// echo $userCon;
 | 
	
		
			
				|  |  | +			$sidList = $staff->getStaffByWxid ( $userCon );
 | 
	
		
			
				|  |  | +			foreach ( $sidList as $key => $value ) {
 | 
	
		
			
				|  |  | +				$falg = $this->isSendNotification ( $value ['sid'], 'receivables' );
 | 
	
		
			
				|  |  | +				if ($falg) {
 | 
	
		
			
				|  |  | +					array_push ( $wxList, $value ['wxid'] );
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			$wxString = implode ( '|', $wxList );
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return $wxString;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 读取发送信息规则判断是否需要发送
 | 
	
		
			
				|  |  | +	 * @param number $sid
 | 
	
		
			
				|  |  | +	 * @param string $sendType
 | 
	
		
			
				|  |  | +	 * @return boolean
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	function isSendNotification($sid = 0, $sendType = '') {
 | 
	
		
			
				|  |  | +		Doo::loadModel ( "notificationConf" );
 | 
	
		
			
				|  |  | +		$notificationConf = new notificationConf ();
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$detail = $notificationConf->getNotificationConfBySid ( $sid );
 | 
	
		
			
				|  |  | +		
 | 
	
		
			
				|  |  | +		$conf = array ();
 | 
	
		
			
				|  |  | +		$sendFlag = true;
 | 
	
		
			
				|  |  | +		if (! empty ( $detail )) {
 | 
	
		
			
				|  |  | +			$conf = json_decode ( $detail ['conf'], true );
 | 
	
		
			
				|  |  | +			if (! empty ( $sendType )) {
 | 
	
		
			
				|  |  | +				if (isset ( $conf [$sendType] )) {
 | 
	
		
			
				|  |  | +					if ($conf [$sendType] == "CLOSE")
 | 
	
		
			
				|  |  | +						$sendFlag = false;
 | 
	
		
			
				|  |  | +					elseif ($conf [$sendType] == "Weekend") {
 | 
	
		
			
				|  |  | +						$day = date ( "w" );
 | 
	
		
			
				|  |  | +						if (1 <= $day && 5 >= $day)
 | 
	
		
			
				|  |  | +							$sendFlag = false;
 | 
	
		
			
				|  |  | +					} elseif ($conf [$sendType] == "OneToFriday") {
 | 
	
		
			
				|  |  | +						$day = date ( "w" );
 | 
	
		
			
				|  |  | +						if (0 == $day || 6 == $day)
 | 
	
		
			
				|  |  | +							$sendFlag = false;
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			} else
 | 
	
		
			
				|  |  | +				$sendFlag = false;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return $sendFlag;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 根据规则发送信息
 | 
	
		
			
				|  |  | +	 * @param unknown $msg
 | 
	
		
			
				|  |  | +	 * @param unknown $title
 | 
	
		
			
				|  |  | +	 * @param unknown $url
 | 
	
		
			
				|  |  | +	 * @param unknown $user
 | 
	
		
			
				|  |  | +	 * @param string $text
 | 
	
		
			
				|  |  | +	 * @return number
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	private function msgSend($msg, $title, $url, $user, $sid = 0, $sendType = '') {
 | 
	
		
			
				|  |  |  		$token = $this->getAccessToken ();
 | 
	
		
			
				|  |  | -		if ($text == 'text') {
 | 
	
		
			
				|  |  | -			$data = '{
 | 
	
		
			
				|  |  | -   				"touser": "' . $user . '",
 | 
	
		
			
				|  |  | -   				"toparty": "",
 | 
	
		
			
				|  |  | -   				"totag": "",
 | 
	
		
			
				|  |  | -  				"msgtype": "text",
 | 
	
		
			
				|  |  | -   				"agentid": 1000002,
 | 
	
		
			
				|  |  | -   				"text": {
 | 
	
		
			
				|  |  | -       				"content": "' . $msg . '"
 | 
	
		
			
				|  |  | -   				},
 | 
	
		
			
				|  |  | -   				"safe":0
 | 
	
		
			
				|  |  | -			}';
 | 
	
		
			
				|  |  | -		} else {
 | 
	
		
			
				|  |  | -			$data = '{
 | 
	
		
			
				|  |  | +		$falg = $this->isSendNotification ( $sid, $sendType );
 | 
	
		
			
				|  |  | +		// if ($text == 'text') {
 | 
	
		
			
				|  |  | +		// $data = '{
 | 
	
		
			
				|  |  | +		// "touser": "' . $user . '",
 | 
	
		
			
				|  |  | +		// "toparty": "",
 | 
	
		
			
				|  |  | +		// "totag": "",
 | 
	
		
			
				|  |  | +		// "msgtype": "text",
 | 
	
		
			
				|  |  | +		// "agentid": 1000002,
 | 
	
		
			
				|  |  | +		// "text": {
 | 
	
		
			
				|  |  | +		// "content": "' . $msg . '"
 | 
	
		
			
				|  |  | +		// },
 | 
	
		
			
				|  |  | +		// "safe":0
 | 
	
		
			
				|  |  | +		// }';
 | 
	
		
			
				|  |  | +		// } else {
 | 
	
		
			
				|  |  | +		$data = '{
 | 
	
		
			
				|  |  |  				"touser": "' . $user . '",
 | 
	
		
			
				|  |  |     				"toparty": "",
 | 
	
		
			
				|  |  |     				"totag": "",
 | 
	
	
		
			
				|  | @@ -4497,13 +4633,16 @@ class InvoiceController extends DooController {
 | 
	
		
			
				|  |  |             			]
 | 
	
		
			
				|  |  |     				}
 | 
	
		
			
				|  |  |  			}';
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		$result = json_decode ( $this->httpPOST ( "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={$token}", $data ) );
 | 
	
		
			
				|  |  | -		if ($result->errmsg != 'ok') {
 | 
	
		
			
				|  |  | +		// }
 | 
	
		
			
				|  |  | +		if ($falg) {
 | 
	
		
			
				|  |  | +			$result = json_decode ( $this->httpPOST ( "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={$token}", $data ) );
 | 
	
		
			
				|  |  | +			if ($result->errmsg != 'ok') {
 | 
	
		
			
				|  |  | +				return 0;
 | 
	
		
			
				|  |  | +			} else {
 | 
	
		
			
				|  |  | +				return 1;
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		} else
 | 
	
		
			
				|  |  |  			return 0;
 | 
	
		
			
				|  |  | -		} else {
 | 
	
		
			
				|  |  | -			return 1;
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  	private function getAccessToken() {
 | 
	
		
			
				|  |  |  		// access_token 应该全局存储与更新,以下代码以写入到文件中做示例
 |