dever 6 years ago
parent
commit
6b06936ce5
2 changed files with 11 additions and 6 deletions
  1. 5 4
      applet/src/Msg.php
  2. 6 2
      main/lib/Core.php

+ 5 - 4
applet/src/Msg.php

@@ -66,7 +66,7 @@ class Msg
 	}
 
 	# 发送单条模板消息
-	public function sendOne($key, $project_id, $touser, $page, $data, $form_id, $emphasis_keyword = '')
+	public function sendOne($key, $project_id, $touser, $page, $data, $form_id, $emphasis_keyword = '', $state = false)
 	{
 		if ($project_id > 0 && $key && $touser && $page && $data) {
 			$info = Dever::db('applet/msg')->one(array('option_key' => $key, 'option_project_id' => $project_id));
@@ -93,7 +93,7 @@ class Msg
 
 				$id = Dever::upinto('applet/msg_log', $where, $update);
 
-				Core::run($info['project_id'], 'send_msg', 'msg.sendAction', 'msg.sendLog', 'applet', $id);
+				Core::run($info['project_id'], 'send_msg', 'msg.sendAction', 'msg.sendLog', 'applet', $id, $state);
 			}
 		}
 	}
@@ -138,14 +138,15 @@ class Msg
 		//没发送10次,休息3秒
 		$time = 3;
 		$num = 0;
+		$state = true;//同步发送
 		while ($state == true) {
 			$data = Dever::pop();
 			if ($data) {
 				$num++;
 				$state = true;
-				$this->sendOne($data['key'], $data['project_id'], $data['touser'], $data['page'], $data['data'], $data['form_id'], $data['emphasis_keyword']);
+				$this->sendOne($data['key'], $data['project_id'], $data['touser'], $data['page'], $data['data'], $data['form_id'], $data['emphasis_keyword'], $state);
 
-				if ($num == 10) {
+				if ($state == false && $num == 10) {
 					$num = 0;
 					sleep(3);
 				}

+ 6 - 2
main/lib/Core.php

@@ -5,7 +5,7 @@ use Dever;
 
 class Core
 {
-	static public function run($id, $method, $start, $end, $app, $param = false)
+	static public function run($id, $method, $start, $end, $app, $param = false, $state = false)
 	{
 		$send = array();
 		$send['i'] = $id;
@@ -14,7 +14,11 @@ class Core
 		$send['e'] = $end;
 		$send['a'] = $app;
 		$send['p'] = $param;
-		$result = Dever::daemon(self::url($send), 'main');
+		if ($state == false) {
+			$result = Dever::daemon(self::url($send), 'main');
+		} else {
+			$result = Dever::load('main/' . self::url($send));
+		}
 
 		return $result;
 	}