DotTest.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <?php
  2. use app\admin\model\ReadNavigation;
  3. use app\common\library\Redis;
  4. use app\main\constants\CacheConstants;
  5. use app\main\service\ExportFansService;
  6. use app\main\service\HigeMessageService;
  7. use app\main\service\LogService;
  8. use app\main\service\MqUserPayCancelService;
  9. /**
  10. * Created by PhpStorm.
  11. * User: wanggb
  12. * Date: 2018/11/29
  13. * Time: 15:47
  14. */
  15. class DotTest extends TestInit
  16. {
  17. /* protected $dot = null;
  18. public function __construct()
  19. {
  20. $this->dot = \app\main\service\UserdotService::instance();
  21. }*/
  22. public function testSendSingleProcess()
  23. {
  24. $export = ExportFansService::instance()->checkFansLead(1807, 22288)->data;
  25. $data = nl2br($export['content']);
  26. $url = getCurrentDomain(1807, '/index/share/leadpage?id='.$export['id'].'&from=wx');
  27. $content = '';
  28. if (strrpos($data, '<br />') != false) {
  29. foreach (explode('<br />', $data) as $v) {
  30. $v = preg_replace('|\s|', '', $v);
  31. //$v = str_replace([PHP_EOL, ' ', '\r\n'], ['', '', ''], $v);
  32. var_dump($v);
  33. //$content .= "<a href='{$url}'>{$v}</a>\r\n";
  34. }
  35. } else {
  36. $content .= "<a href='{$url}'>{$export['content']}</a>\r\n\r\n";
  37. }
  38. //var_dump($content);
  39. die;
  40. //\app\main\service\ReferralService::instance()->sendReferralAdData(989, ['admin_id' => 1734, 'url' => "http://wx5c755b34fe1d1111.dev.kpread.com/index/user/recent", 'orders' => ['money' =>0.01, 'productName' => "测试一下001"], 'openid' => "oiYYI1r5ZYS78UECy-6xJnr4Wk5U"]);
  41. //\app\main\service\ReferralService::instance()->sendReferralAdData(989, ['admin_id' => 1734, 'url' => "http://wx5c755b34fe1d1111.dev.kpread.com/index/user/index", 'sub' => ['productName' => "测试一下001"], 'openid' => "oIOef0ZFczbEvg4I6d12FLgpAcI0"]);
  42. $dot = \app\main\service\UserdotService::instance();
  43. $message = [
  44. 'user_id' => 19335706,
  45. 'channel_id' => 3,
  46. 'action_type' => 'obscuresubscribe.referral',
  47. 'referral_id' => 706,
  48. 'type' => 4,
  49. 'event_time' => time(),
  50. ];
  51. $messageObj = (new \app\main\model\object\DotObject())->bind($message);
  52. for ($i = 0; $i < 1000; $i++) {
  53. $dot->handleTask($messageObj);
  54. }
  55. }
  56. public function testSendMultiProcess_10()
  57. {
  58. $dot = \app\main\service\UserdotService::instance();
  59. $message = [
  60. 'user_id' => 19335706,
  61. 'channel_id' => 3,
  62. 'action_type' => 'obscuresubscribe.referral',
  63. 'referral_id' => 706,
  64. 'type' => 4,
  65. 'event_time' => time(),
  66. ];
  67. $messageObj = (new \app\main\model\object\DotObject())->bind($message);
  68. $i = 0;
  69. while ($i < 10) {
  70. $pid = pcntl_fork();
  71. echo "pid:" . $pid . ",$i\n";
  72. echo "current_id:" . getmypid() . ",$i\n";
  73. switch ($pid) {
  74. case -1:
  75. // @fail
  76. die('Fork failed');
  77. break;
  78. case 0:
  79. $j = 0;
  80. while ($j < 1000) {
  81. $dot->handleTask($messageObj);
  82. $j++;
  83. }
  84. exit(0);
  85. break;
  86. }
  87. $i++;
  88. }
  89. }
  90. public function testSendMultiProcess_50()
  91. {
  92. $dot = \app\main\service\UserdotService::instance();
  93. $message = [
  94. 'user_id' => 19335706,
  95. 'channel_id' => 3,
  96. 'action_type' => 'obscuresubscribe.referral',
  97. 'referral_id' => 706,
  98. 'type' => 4,
  99. 'event_time' => time(),
  100. ];
  101. $messageObj = (new \app\main\model\object\DotObject())->bind($message);
  102. $i = 0;
  103. while ($i < 50) {
  104. $pid = pcntl_fork();
  105. echo "pid:" . $pid . ",$i\n";
  106. echo "current_id:" . getmypid() . ",$i\n";
  107. switch ($pid) {
  108. case -1:
  109. // @fail
  110. die('Fork failed');
  111. break;
  112. case 0:
  113. $j = 0;
  114. while ($j < 200) {
  115. $dot->handleTask($messageObj);
  116. $j++;
  117. }
  118. exit(0);
  119. break;
  120. }
  121. $i++;
  122. }
  123. }
  124. public function testSendMultiProcess_100()
  125. {
  126. $dot = \app\main\service\UserdotService::instance();
  127. $message = [
  128. 'user_id' => 19335706,
  129. 'channel_id' => 3,
  130. 'action_type' => 'obscuresubscribe.referral',
  131. 'referral_id' => 706,
  132. 'type' => 4,
  133. 'event_time' => time(),
  134. ];
  135. $messageObj = (new \app\main\model\object\DotObject())->bind($message);
  136. $i = 0;
  137. while ($i < 100) {
  138. $pid = pcntl_fork();
  139. echo "pid:" . $pid . ",$i\n";
  140. echo "current_id:" . getmypid() . ",$i\n";
  141. switch ($pid) {
  142. case -1:
  143. // @fail
  144. die('Fork failed');
  145. break;
  146. case 0:
  147. $j = 0;
  148. while ($j < 100) {
  149. $dot->handleTask($messageObj);
  150. $j++;
  151. }
  152. exit(0);
  153. break;
  154. }
  155. $i++;
  156. }
  157. }
  158. public function testUvTest()
  159. {
  160. $dotData = \app\main\service\SmartPushDotService::instance()->generateKefuData(
  161. 1022,
  162. 17,
  163. 0,
  164. time(),
  165. 3
  166. );
  167. \app\main\service\SmartPushDotService::instance()->dotSmartPushInfo($dotData);
  168. }
  169. public function testSubTest()
  170. {
  171. $dotData = \app\main\service\SmartPushDotService::instance()->generateSubData(
  172. 1022,
  173. 17,
  174. time(),
  175. 3
  176. );
  177. \app\main\service\SmartPushDotService::instance()->dotSmartPushInfo($dotData);
  178. }
  179. public function testPay()
  180. {
  181. $dotData = \app\main\service\SmartPushDotService::instance()->generatePayData(
  182. 1022,
  183. 17,
  184. 2,
  185. time(),
  186. 10
  187. );
  188. \app\main\service\SmartPushDotService::instance()->dotSmartPushInfo($dotData);
  189. }
  190. public function testBooklistDot()
  191. {
  192. (new \app\common\model\Platform())->delCacheAll(3);
  193. \app\main\service\OpenPlatformService::instance()->getProfixconfigById(3);
  194. die;
  195. $redisKey = 'text1234';
  196. $res = \app\common\library\Redis::instance()->hMSet($redisKey, []);
  197. var_dump($res);
  198. \app\common\library\Redis::instance()->expire($redisKey, 600);
  199. /* $ext_data = [
  200. 'mark' => 3501,
  201. 'push_id' => 7,
  202. 'push_idx' => '11000000040',
  203. 'push_time' => time(),
  204. 'admin_id' => 1734
  205. ];
  206. $dotData = \app\main\service\SmartPushDotService::instance()->generateDotData(
  207. $ext_data['mark'],
  208. $ext_data['push_id'] ?? 0,
  209. $ext_data['push_idx'] ?? BigData::DEFAULT_PUSH_IDX,
  210. $ext_data['push_time'] ?? time(),
  211. time(),
  212. array_merge(['type' => 1, 'user_id' => 3], $ext_data)
  213. );
  214. \app\main\service\SmartPushDotService::instance()->dotSmartPushInfo($dotData);*/
  215. }
  216. public function testCustomDot()
  217. {
  218. $data['user_id'] = 20001433;
  219. $data['openid'] = 'oiYYI1l0kANcDG6Ti8B7Tjr45xbU';
  220. $data['goods_id'] = '3';
  221. $data['channel_id'] = '1734';
  222. $msg2 = [];
  223. $msg2['title'] = '首充';
  224. $msg2['image'] = 'http://cpsn.dev.kpread.com/assets/img/qrcode.png';
  225. $msg2['url'] = 'http://wx5c755b34fe1d1111.dev.kpread.com/s/100?user_id=20001433';
  226. $msg2['description'] = '书币半价,仅限前100名';
  227. $data['msg'] = $msg2;
  228. MqUserPayCancelService::instance()->sendFirstCancel($data, 0);
  229. }
  230. }