123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <?php
- use app\admin\model\ReadNavigation;
- use app\common\library\Redis;
- use app\main\constants\CacheConstants;
- use app\main\service\ExportFansService;
- use app\main\service\HigeMessageService;
- use app\main\service\LogService;
- use app\main\service\MqUserPayCancelService;
- /**
- * Created by PhpStorm.
- * User: wanggb
- * Date: 2018/11/29
- * Time: 15:47
- */
- class DotTest extends TestInit
- {
- /* protected $dot = null;
- public function __construct()
- {
- $this->dot = \app\main\service\UserdotService::instance();
- }*/
- public function testSendSingleProcess()
- {
- $export = ExportFansService::instance()->checkFansLead(1807, 22288)->data;
- $data = nl2br($export['content']);
- $url = getCurrentDomain(1807, '/index/share/leadpage?id='.$export['id'].'&from=wx');
- $content = '';
- if (strrpos($data, '<br />') != false) {
- foreach (explode('<br />', $data) as $v) {
- $v = preg_replace('|\s|', '', $v);
- //$v = str_replace([PHP_EOL, ' ', '\r\n'], ['', '', ''], $v);
- var_dump($v);
- //$content .= "<a href='{$url}'>{$v}</a>\r\n";
- }
- } else {
- $content .= "<a href='{$url}'>{$export['content']}</a>\r\n\r\n";
- }
- //var_dump($content);
- die;
- //\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"]);
- //\app\main\service\ReferralService::instance()->sendReferralAdData(989, ['admin_id' => 1734, 'url' => "http://wx5c755b34fe1d1111.dev.kpread.com/index/user/index", 'sub' => ['productName' => "测试一下001"], 'openid' => "oIOef0ZFczbEvg4I6d12FLgpAcI0"]);
- $dot = \app\main\service\UserdotService::instance();
- $message = [
- 'user_id' => 19335706,
- 'channel_id' => 3,
- 'action_type' => 'obscuresubscribe.referral',
- 'referral_id' => 706,
- 'type' => 4,
- 'event_time' => time(),
- ];
- $messageObj = (new \app\main\model\object\DotObject())->bind($message);
- for ($i = 0; $i < 1000; $i++) {
- $dot->handleTask($messageObj);
- }
- }
- public function testSendMultiProcess_10()
- {
- $dot = \app\main\service\UserdotService::instance();
- $message = [
- 'user_id' => 19335706,
- 'channel_id' => 3,
- 'action_type' => 'obscuresubscribe.referral',
- 'referral_id' => 706,
- 'type' => 4,
- 'event_time' => time(),
- ];
- $messageObj = (new \app\main\model\object\DotObject())->bind($message);
- $i = 0;
- while ($i < 10) {
- $pid = pcntl_fork();
- echo "pid:" . $pid . ",$i\n";
- echo "current_id:" . getmypid() . ",$i\n";
- switch ($pid) {
- case -1:
- // @fail
- die('Fork failed');
- break;
- case 0:
- $j = 0;
- while ($j < 1000) {
- $dot->handleTask($messageObj);
- $j++;
- }
- exit(0);
- break;
- }
- $i++;
- }
- }
- public function testSendMultiProcess_50()
- {
- $dot = \app\main\service\UserdotService::instance();
- $message = [
- 'user_id' => 19335706,
- 'channel_id' => 3,
- 'action_type' => 'obscuresubscribe.referral',
- 'referral_id' => 706,
- 'type' => 4,
- 'event_time' => time(),
- ];
- $messageObj = (new \app\main\model\object\DotObject())->bind($message);
- $i = 0;
- while ($i < 50) {
- $pid = pcntl_fork();
- echo "pid:" . $pid . ",$i\n";
- echo "current_id:" . getmypid() . ",$i\n";
- switch ($pid) {
- case -1:
- // @fail
- die('Fork failed');
- break;
- case 0:
- $j = 0;
- while ($j < 200) {
- $dot->handleTask($messageObj);
- $j++;
- }
- exit(0);
- break;
- }
- $i++;
- }
- }
- public function testSendMultiProcess_100()
- {
- $dot = \app\main\service\UserdotService::instance();
- $message = [
- 'user_id' => 19335706,
- 'channel_id' => 3,
- 'action_type' => 'obscuresubscribe.referral',
- 'referral_id' => 706,
- 'type' => 4,
- 'event_time' => time(),
- ];
- $messageObj = (new \app\main\model\object\DotObject())->bind($message);
- $i = 0;
- while ($i < 100) {
- $pid = pcntl_fork();
- echo "pid:" . $pid . ",$i\n";
- echo "current_id:" . getmypid() . ",$i\n";
- switch ($pid) {
- case -1:
- // @fail
- die('Fork failed');
- break;
- case 0:
- $j = 0;
- while ($j < 100) {
- $dot->handleTask($messageObj);
- $j++;
- }
- exit(0);
- break;
- }
- $i++;
- }
- }
- public function testUvTest()
- {
- $dotData = \app\main\service\SmartPushDotService::instance()->generateKefuData(
- 1022,
- 17,
- 0,
- time(),
- 3
- );
- \app\main\service\SmartPushDotService::instance()->dotSmartPushInfo($dotData);
- }
- public function testSubTest()
- {
- $dotData = \app\main\service\SmartPushDotService::instance()->generateSubData(
- 1022,
- 17,
- time(),
- 3
- );
- \app\main\service\SmartPushDotService::instance()->dotSmartPushInfo($dotData);
- }
- public function testPay()
- {
- $dotData = \app\main\service\SmartPushDotService::instance()->generatePayData(
- 1022,
- 17,
- 2,
- time(),
- 10
- );
- \app\main\service\SmartPushDotService::instance()->dotSmartPushInfo($dotData);
- }
- public function testBooklistDot()
- {
- (new \app\common\model\Platform())->delCacheAll(3);
- \app\main\service\OpenPlatformService::instance()->getProfixconfigById(3);
- die;
- $redisKey = 'text1234';
- $res = \app\common\library\Redis::instance()->hMSet($redisKey, []);
- var_dump($res);
- \app\common\library\Redis::instance()->expire($redisKey, 600);
- /* $ext_data = [
- 'mark' => 3501,
- 'push_id' => 7,
- 'push_idx' => '11000000040',
- 'push_time' => time(),
- 'admin_id' => 1734
- ];
- $dotData = \app\main\service\SmartPushDotService::instance()->generateDotData(
- $ext_data['mark'],
- $ext_data['push_id'] ?? 0,
- $ext_data['push_idx'] ?? BigData::DEFAULT_PUSH_IDX,
- $ext_data['push_time'] ?? time(),
- time(),
- array_merge(['type' => 1, 'user_id' => 3], $ext_data)
- );
- \app\main\service\SmartPushDotService::instance()->dotSmartPushInfo($dotData);*/
- }
- public function testCustomDot()
- {
- $data['user_id'] = 20001433;
- $data['openid'] = 'oiYYI1l0kANcDG6Ti8B7Tjr45xbU';
- $data['goods_id'] = '3';
- $data['channel_id'] = '1734';
- $msg2 = [];
- $msg2['title'] = '首充';
- $msg2['image'] = 'http://cpsn.dev.kpread.com/assets/img/qrcode.png';
- $msg2['url'] = 'http://wx5c755b34fe1d1111.dev.kpread.com/s/100?user_id=20001433';
- $msg2['description'] = '书币半价,仅限前100名';
- $data['msg'] = $msg2;
- MqUserPayCancelService::instance()->sendFirstCancel($data, 0);
- }
- }
|