'v1.0',
'pkna' => '22',
'chid' => '1',
'app' => '1',
'ptx' => '1',
'ua' => '1',
'p' => '1',
];
echo json_encode($common);
}
public function test00()
{
}
public function mqtest()
{
echo 'MqTest:'.time();
$mq = MqService::instance()->getDotMqInstance();
$exchangename='cps.ex.topic';
$routing_key = 'collect.user.subscribe1';
$data = [
'admin_id' => 2,
'user_id' => 3,
'type' => 1,
'event_time' => time(),
'business_line' => 0
];
$mq->transferExchange($data, $exchangename, $routing_key, 'topic');
}
public function test01()
{
$arr = [
[
'title' => '你为什么还没不到口罩',
'author' => '回环针',
'cover' => './uploads/20200229/17afc3c90f68c2a46c7e36024e6589a2.png',
'content' => '国家出手控制口罩',
'digest' => '1',
'need_open_comment' => 0,
'only_fans_can_comment' => 0,
'type' => 0,
'book_id' => 1111111111,
'chapter_id' => 222222,
]
];
//UserSilentService::instance()->refactorUrl();
try{
// 文字
/*HigeMessageService::instance()->sent(
[1734],
50000207,
1,
[
[
'content' => '文字消息内容002',
'is_url' => 0,
]]
);*/
// 图文
HigeMessageService::instance()->sent(
[1734],
50000207,
2,
$arr
);
}catch (\Exception $exception){
echo $exception->getMessage();
}
echo 'Success'.time();
}
public function test0()
{
$channel_id = 1749;
$adminConfig = new AdminConfig();
$adminInfo = $adminConfig->getAdminInfoAll($channel_id);
$wechat = new WeChatObject($adminInfo);
$officialAccount = $wechat->getOfficialAccount();
$list = $officialAccount->user_tag->list();
print_r('');
die();
}
/**
* 无需登录的接口
*
* 必选参数:无
* 可选参数:无
*/
public function test1()
{
$this->mkCommon();
die();
$this->success('返回成功', ['action' => 'test1']);
}
public function test9()
{
//$this->outSql();
$data = NovelyoulikeService::instance()->getNovelRecommend();
print_r($data);
die();
}
public function outSql(){
for ($i= 256; $i<=512; $i++){
echo "USE test_cps_user_{$i}; ALTER TABLE recharge DROP COLUMN deduct; ALTER TABLE recharge ADD COLUMN `dd` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否扣量'; ";
echo PHP_EOL;
echo "
";
}
exit();
}
/**
* 需要登录的接口
*
* 必选参数:token
* 可选参数:无
*/
public function test2()
{
Redis::instance()->sadd('nihao2',2,4,3);
$r = Redis::instance()->sRandMember('nihao2');
dump($r);
$this->success('返回成功', ['action' => 'test2']);
}
/**
* 需要登录的接口
*
* 必选参数:token
* 可选参数:无
*/
public function test3()
{
$dotData = SmartPushDotService::instance()->generateKefuData(
2000,
0,
0,
9999
);
SmartPushDotService::instance()->dotSmartPushInfo($dotData);
echo 'OK'.time();
}
public function test4()
{
$default_menu_obj = model('config')->where(['name'=>'wx_menu'])->field('value')->find();
$default_menu_arr = json_decode($default_menu_obj->value, true);
$arr = [
['name' => '阅读记录'],
['name' => '精品推荐'],
['name' => '用户中心']
];
var_dump($this->isConsistent($default_menu_arr, $arr));
die();
}
public function test5()
{
// 测试打点, 将数据压入到MQ
try{
$dotData = new DotObject();
$dotData->user_id = 50000207;
$dotData->channel_id = 1734;
$dotData->sex = 2;
$dotData->business_line = '1';
//$dotData->action_type = MqConstants::ROUTING_KEY_APP_REGISTER;
//$dotData->type = MqConstants::MSG_TYPE_APP_REGISTER;
//$dotData->action_type = MqConstants:: ROUTING_KEY_APP_BIND;
//$dotData->type = MqConstants::MSG_TYPE_APP_BIND;
$dotData->action_type = MqConstants:: ROUTING_KEY_APP_BIND_CODE;
$dotData->type = MqConstants::MSG_TYPE_APP_BIND_CODE;
$dotData->event_time = Request::instance()->server('REQUEST_TIME');
MqService::instance()->sendMessage($dotData);
echo 'OK->'.date('Y-m-d', time());
}catch (\Exception $exception){
print_r($exception);
die();
}
}
public function test6()
{
//发送打点数据
$dotData = new DotObject();
//打点信息初始化
$dotData->channel_id = 1734;
$dotData->user_id = 4;
$dotData->event_time = time();;
$dotData->is_first_follow = 1;
$dotData->sex = 2;
$dotData->action_type = MqConstants::ROUTING_KEY_SUBSCRIBE;
$dotData->type = MqConstants::MSG_TYPE_SEX;
MqService::instance()->sendMessage($dotData);
}
/**
* 打点APP下载引导页UV
*/
public function test7()
{
//发送打点数据
$dotData = new DotObject();
//打点信息初始化
$dotData->channel_id = 1734;
$dotData->user_id = 13;
$dotData->event_time = time();
$dotData->action_type = MqConstants::ROUTING_KEY_APP_GUIDE_UV;
$dotData->guide_idx = 1;
$dotData->guide_op_type = 1;
MqService::instance()->sendMessage($dotData);
echo 'Success ##'. time();
}
public function test8($uid, $kandian)
{
UserService::instance()->addFreeKanDian($uid, $kandian, time(), 'APP用户绑定手机号赠送书币');
echo "添加书币成功:{$uid} , {$kandian}";
}
/**
* @param $uid
*/
public function clearbindcode($uid)
{
UserService::instance()->update(['bindtime' => ''], ['id' => $uid]);
echo 'Success::'.date('Y-m-d H:i:s', time());
}
/**
* 清空用户绑定的手机号
* @param $uid
*/
public function clearbindappuser($uid)
{
UserService::instance()->update(['mobile' => '', 'bindtime' => ''], ['id' => $uid]);
$redis = Redis::instance();
$key = 'UN:' . $uid;
$redis->del($key);
echo 'Scuccess, 清空用户绑定的手机号' . date('Y-m-d H:i:s', time());
}
public function clearappuserphone($phone)
{
$res = model('UserPhone')->setConnect($phone)->where('phone', '=', $phone)->delete();
$redis = Redis::instance();
$key = 'UPHONE:' . $phone;
$redis->del($key);
echo "Success,根据手机号清空用户信息" . date('Y-m-d H:i:s', time());
}
public function isConsistent(array $defalt_menu_arr, array $b_arr)
{
$defalt_name_arr = array_column($defalt_menu_arr, 'name');
$b_name_arr = array_column($b_arr, 'name');
$diff = array_diff_assoc($defalt_name_arr, $b_name_arr);
if(!empty($diff)){
return false;
}else{
foreach ($defalt_menu_arr as $key => $default_item)
{
if(isset($default_item['sub_button'])){
$default_sub_btn_arr = array_column($default_item['sub_button'], 'name');
$b_sub_btn_arr = isset($b_arr[$key]['sub_button']) ? array_column($b_arr[$key]['sub_button'], 'name') : array();
$diff_sub_btn = array_diff_assoc($default_sub_btn_arr, $b_sub_btn_arr);
if($diff_sub_btn){
return false;
}
}
}
}
return true;
}
}