edit-sylive-kpidata
This commit is contained in:
@@ -680,4 +680,54 @@ class Syt extends CI_Controller
|
||||
}
|
||||
echo '执行结束';
|
||||
}
|
||||
|
||||
public function kpi(){
|
||||
$this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData');
|
||||
$this->load->model('market/market_sylive_order_model','order_model');
|
||||
$this->load->model('market/market_sylive_activity_user_model', 'act_user_model');
|
||||
$this->load->model('market/market_sylive_groups_user_model', 'groups_user_model');
|
||||
$this->load->model('market/market_sylive_subscribemsg_model', 'mdSytSubscribemsg');
|
||||
$page = $this->input->get('page');
|
||||
$size = $this->input->get('size');
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 20;
|
||||
$where = [
|
||||
'activityId' => 6,
|
||||
'id<=' => 91939,
|
||||
'pid>' => 0,
|
||||
"pid != channelId" => null
|
||||
];
|
||||
$rows = $this->act_user_model->select($where,'id desc',$page,$size);
|
||||
if($rows){
|
||||
foreach ($rows as $key => $val) {
|
||||
//查找是否是管理员
|
||||
$group_user = $this->groups_user_model->get(['status'=>0,'activityId'=>6,'userId'=>$val['userId']]);
|
||||
if($group_user){
|
||||
if($group_user['userId']!=$val['channelId']){
|
||||
$this->act_user_model->update(['channelId'=>$group_user['userId']],['id'=>$val['id']]);
|
||||
echo "管理员更新成功:{$val['id']},".json_encode(['channelId'=>$group_user['userId']])."\n";
|
||||
}else{
|
||||
echo "无需更新:{$val['id']}\n";
|
||||
}
|
||||
}else{
|
||||
//查找上级
|
||||
$p_act_user = $this->act_user_model->get(['userId'=>$val['pid'],'activityId'=>6]);
|
||||
$update = [];
|
||||
if($p_act_user['channelId']){
|
||||
$update['channelId'] = $p_act_user['channelId'];
|
||||
}else{
|
||||
$p_act_user['groupsId'] && $update['channelId'] = $p_act_user['userId'];
|
||||
}
|
||||
if($update && $update['channelId']!=$val['channelId']){
|
||||
$this->act_user_model->update($update,['id'=>$val['id']]);
|
||||
echo "更新成功:{$val['id']},".json_encode($update)."\n";
|
||||
}else{
|
||||
echo "无需更新:{$val['id']}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo '执行结束';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1375,4 +1375,105 @@ class Temp extends HD_Controller
|
||||
echo 'finish';
|
||||
}
|
||||
}
|
||||
|
||||
public function syt_sub(){
|
||||
$this->load->model('market/market_sylive_subscribemsg_model', 'mdSytSubscribemsg');
|
||||
$this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData');
|
||||
$this->load->model('market/market_sylive_activity_user_model', 'act_user_model');
|
||||
$this->load->library('market/sylive2_entity');
|
||||
$page = $this->input->get('page');
|
||||
$size = $this->input->get('size');
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 20;
|
||||
$where = [
|
||||
'activityId' => 6,
|
||||
'id<' => 65233
|
||||
];
|
||||
$rows = $this->mdSytSubscribemsg->select($where,'id desc',$page,$size);
|
||||
if($rows){
|
||||
foreach ($rows as $key => $val) {
|
||||
$act_user = $this->act_user_model->get(['userId'=>$val['userId'],'activityId'=>6]);
|
||||
$fy_log = $this->mdSytActivityKpiData->get(['userId'=>$val['userId'],'activityId'=>6,'kpi'=>'subscribe']);
|
||||
if(!$fy_log){
|
||||
//判断浏览数据是否存在
|
||||
$browse_log = $this->mdSytActivityKpiData->get(['userId'=>$val['userId'],'activityId'=>6,'kpi'=>'browse']);
|
||||
if(!$browse_log){
|
||||
//浏览
|
||||
$params = array('a_id' => 6, 'uid' => $val['userId'],'cf_uid' => $act_user['channelId'], 'kpi' => 'browse');
|
||||
$req = $this->sylive2_entity->kpi_log($params);
|
||||
echo "{$val['id']},增加浏览数据成功:".json_encode($req,JSON_UNESCAPED_UNICODE)."\n";
|
||||
}
|
||||
//订阅用户加统计
|
||||
$params = array('a_id' => 6, 'uid' => $val['userId'],'cf_uid' => $act_user['channelId'], 'kpi' => 'subscribe');
|
||||
$req = $this->sylive2_entity->kpi_log($params);
|
||||
echo "{$val['id']},增加订阅数据成功:".json_encode($req,JSON_UNESCAPED_UNICODE)."\n";
|
||||
}else{
|
||||
echo "订阅日志已存在\n";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo '执行结束';
|
||||
}
|
||||
}
|
||||
|
||||
public function syt_order(){
|
||||
$this->load->model('market/market_sylive_order_model');
|
||||
$this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData');
|
||||
$this->load->model('market/market_sylive_activity_user_model', 'act_user_model');
|
||||
$this->load->library('market/sylive2_entity');
|
||||
$page = $this->input->get('page');
|
||||
$size = $this->input->get('size');
|
||||
!$page && $page = 1;
|
||||
!$size && $size = 20;
|
||||
$where = [
|
||||
'activityId' => 6,
|
||||
'id<=' => 7750
|
||||
];
|
||||
$rows = $this->market_sylive_order_model->select($where,'id desc',$page,$size);
|
||||
if($rows){
|
||||
foreach ($rows as $key => $val) {
|
||||
$p_user = [];
|
||||
$act_user = $this->act_user_model->get(['userId'=>$val['userId'],'activityId'=>6]);
|
||||
$act_user['channelId'] && $p_user = $this->act_user_model->get(['userId'=>$act_user['channelId'],'activityId'=>6]);
|
||||
if($p_user){
|
||||
$update = [];
|
||||
$p_user['bizId'] && $update['bizId'] = $p_user['bizId'];
|
||||
$p_user['levelId1'] && $update['levelId1'] = $p_user['levelId1'];
|
||||
$p_user['levelId2'] && $update['levelId2'] = $p_user['levelId2'];
|
||||
$p_user['levelId3'] && $update['levelId3'] = $p_user['levelId3'];
|
||||
$p_user['userId'] && $update['cfUserId'] = $p_user['userId'];
|
||||
if($update){
|
||||
$this->market_sylive_order_model->update($update,['id'=>$val['id']]);
|
||||
}
|
||||
$fy_log = $this->mdSytActivityKpiData->get(['userId'=>$val['userId'],'activityId'=>6,'kpi'=>'order']);
|
||||
if(!$fy_log){
|
||||
//判断浏览数据是否存在
|
||||
$browse_log = $this->mdSytActivityKpiData->get(['userId'=>$val['userId'],'activityId'=>6,'kpi'=>'browse']);
|
||||
if(!$browse_log){
|
||||
//浏览
|
||||
$params = array('a_id' => 6, 'uid' => $val['userId'],'cf_uid' => $act_user['channelId'], 'kpi' => 'browse');
|
||||
$req = $this->sylive2_entity->kpi_log($params);
|
||||
echo "{$val['id']},增加浏览数据成功:".json_encode($req,JSON_UNESCAPED_UNICODE)."\n";
|
||||
}
|
||||
//订阅用户加统计
|
||||
$params = [
|
||||
'a_id' => $val['activityId'],
|
||||
'uid' => $val['userId'],
|
||||
'cf_uid' => $act_user['channelId'],
|
||||
'kpi' => 'order',
|
||||
'tagId' => $val['id'],
|
||||
'jsondata'=> ['order_id'=>$val['id'],'sid'=>$val['sid']],
|
||||
'itemId' => $val['itemId']
|
||||
];
|
||||
$sy_res = $this->sylive2_entity->kpi_log($params);
|
||||
echo "{$val['id']},增加订阅数据成功:".json_encode($sy_res,JSON_UNESCAPED_UNICODE)."\n";
|
||||
}else{
|
||||
echo "订单日志已存在\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo '执行结束';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class Sylive2_data_entity{
|
||||
$lists = [];
|
||||
if($total){
|
||||
$rows = $this->ci->mdSytActivityKpiData->select_groupby($groupby, $where, $order, $page, $page_size, $select);
|
||||
$target_rows = [];
|
||||
$biz_rows = $target_rows = [];
|
||||
if($groupby=='bizId'){
|
||||
$biz_ids = implode(',',array_column($rows,'tagId'));
|
||||
$biz_ids && $target_rows = $this->ci->groups_model->map('groupsId','',["groupsId in ($biz_ids)"=>null],'','','','groupsId,groupsName');
|
||||
@@ -44,6 +44,8 @@ class Sylive2_data_entity{
|
||||
}else{ //顾问
|
||||
$user_ids = implode(',',array_column($rows,'tagId'));
|
||||
$user_ids && $target_rows = $this->ci->user_model->map('userId','',["userId in ($user_ids)"=>null],'','','','userId,uname as name,headimg');
|
||||
$biz_ids = implode(',',array_column($rows,'bizId'));
|
||||
$biz_ids && $biz_rows = $this->ci->groups_model->map('groupsId','',["groupsId in ($biz_ids)"=>null],'','','','groupsId,groupsName');
|
||||
}
|
||||
$num_tip = $where['kpi'] == 'order' ? '单' : '人';
|
||||
$start = $page>1 ? ($page-1)*$page_size : 0;
|
||||
@@ -58,8 +60,10 @@ class Sylive2_data_entity{
|
||||
$name = $biz['groupsName'];
|
||||
}else{
|
||||
$org = $target_rows[$val['tagId']] ? $target_rows[$val['tagId']][0] : [];
|
||||
$biz = $biz_rows[$val['bizId']] ? $biz_rows[$val['bizId']][0] : [];
|
||||
$tip = $tagId==$val['cfUserId'] ? '本人' : '';
|
||||
$name = $org['name'];
|
||||
$biz && $name.="{$biz['groupsName']}";
|
||||
$headimg = $org['headimg'];
|
||||
}
|
||||
$lists[] = [
|
||||
|
||||
@@ -46,7 +46,7 @@ class Sylive2_entity{
|
||||
public function kpi_log($params)
|
||||
{
|
||||
if ($params['a_id'] && $params['uid'] && $params['cf_uid']) {
|
||||
$user = $this->user_model->get(['userId'=>$params['cf_uid']]);
|
||||
$user = $this->user_model->get(['userId'=>$params['uid']]);
|
||||
$act_user = $this->act_user_model->get(['activityId'=>$params['a_id'],'userId'=>$params['cf_uid']]);
|
||||
if(!$user || !$act_user){
|
||||
return array('code' => 0, 'msg' => '顾问不存在');
|
||||
|
||||
@@ -193,10 +193,11 @@ class Act extends Wx {
|
||||
$act_user = $this->act_user_model->get(['userId'=>$this->uid,'activityId'=>$a_id]);
|
||||
//订阅用户加统计
|
||||
$params = array('a_id' => $a_id, 'uid' => $this->uid,'cf_uid' => $act_user['channelId'], 'kpi' => 'subscribe');
|
||||
$this->sylive2_entity->kpi_log($params);
|
||||
$p_user = [];
|
||||
$act_user['channelId'] && $p_user = $this->user_model->get(['userId'=>$act_user['channelId']]);
|
||||
$p_user['teamId'] && $show_code = 1;
|
||||
$req = $this->sylive2_entity->kpi_log($params);
|
||||
debug_log("[info]# " . json_encode($req,JSON_UNESCAPED_UNICODE), 'market/sylive','subscribemsg.log');
|
||||
// $p_user = [];
|
||||
// $act_user['channelId'] && $p_user = $this->user_model->get(['userId'=>$act_user['channelId']]);
|
||||
// $p_user['teamId'] && $show_code = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ class Wx extends Common{
|
||||
$row_wechat = $this->groups_user_model->get($where);
|
||||
if(!$row_wechat){
|
||||
$row_wechat = $this->user_model->get(['status'=>0,'openid'=>$openid]);//普通用户角色
|
||||
}
|
||||
}else{}
|
||||
if(!$row_wechat){ //创建用户
|
||||
$add = array(
|
||||
"openid" => $openid,
|
||||
@@ -258,7 +258,7 @@ class Wx extends Common{
|
||||
$row_wechat['levelId2'] && $act_data['levelId2'] = $row_wechat['levelId2'];
|
||||
$row_wechat['levelId3'] && $act_data['levelId3'] = $row_wechat['levelId3'];
|
||||
if($param['cf_uid']){
|
||||
$p_act_user = $this->act_user_model->get(['userId'=>$param['cf_uid']],'userId,channelId');
|
||||
$p_act_user = $this->act_user_model->get(['userId'=>$param['cf_uid'],'activityId'=>$param['a_id']],'userId,channelId');
|
||||
if($p_act_user['channelId']){
|
||||
$act_data['channelId'] = $p_act_user['channelId'];
|
||||
}else{
|
||||
|
||||
@@ -148,7 +148,7 @@ class Item extends Wx{
|
||||
$user = $this->user_model->get(['userId'=>$this->uid]);
|
||||
$act_user = $this->act_user_model->get(['userId'=>$this->uid,'activityId'=>$a_id]);
|
||||
$p_user = [];
|
||||
$act_user['channelId'] && $p_user = $this->act_user_model->get(['userId'=>$act_user['channelId']]);
|
||||
$act_user['channelId'] && $p_user = $this->act_user_model->get(['userId'=>$act_user['channelId'],'activityId'=>$a_id]);
|
||||
$unpay = $this->market_sylive_order_model->get(['itemId'=>$itemId,'activityId'=>$a_id,'status'=>0,'userId'=>$this->uid,'expireTime>'=>time(),'type'=>0]);
|
||||
if(!$unpay){
|
||||
$mb_count = $redis_obj->sCard($mb_key); //获取集合中用户数量
|
||||
|
||||
@@ -390,7 +390,7 @@ class Stic extends Admin{
|
||||
$params['itemId'] && $where['itemId'] = $params['itemId'];
|
||||
$groupby = 'cfUserId';
|
||||
$teamId = $this->uid;
|
||||
$select = 'bizId as teamId2,cfUserId,count(id) as t';
|
||||
$select = 'bizId,cfUserId as tagId,count(id) as t';
|
||||
$order = 't desc,id desc';
|
||||
$res = $this->sylive2_data_entity->top_kpidata($groupby,$where,$order,$page,$size,$select,$teamId);
|
||||
$lists = [];
|
||||
|
||||
@@ -95,6 +95,8 @@ class User extends Admin
|
||||
$day = date('Y-m-d H:i:s');
|
||||
$where = [
|
||||
'userId' => $this->uid,
|
||||
'status' => 0,
|
||||
'type' => 1,
|
||||
"activityId in (select activityId from lc_market_sylive_activity where timeEnd>'{$day}' and status=0)" => null
|
||||
];
|
||||
$admin_lists = $this->groups_user_model->select($where,'groupsUserId desc',0,0,$filed);
|
||||
@@ -109,7 +111,7 @@ class User extends Admin
|
||||
'levelId3' => $val['levelId3'],
|
||||
'userFrom' => $val['userFrom'],
|
||||
'userId' => $id,
|
||||
'createTime' => time()
|
||||
'createTime' => date('Y-m-d H:i:s')
|
||||
];
|
||||
}
|
||||
$this->groups_user_model->add_batch($add_data);
|
||||
@@ -158,13 +160,14 @@ class User extends Admin
|
||||
$this->show_json('', 400, '参数错误');
|
||||
}
|
||||
$this->user_model->update(['status' => $status], ['userId' => $userId]);
|
||||
if(!$status){
|
||||
if($status){
|
||||
$day = date('Y-m-d H:i:s');
|
||||
$where = [
|
||||
'userId' => $userId,
|
||||
'status>=' => 0,
|
||||
"activityId in (select activityId from lc_market_sylive_activity where timeEnd>'{$day}' and status=0)" => null
|
||||
];
|
||||
$this->groups_user_model->delete($where);
|
||||
$this->groups_user_model->update(['status'=>-1],$where);
|
||||
}
|
||||
$this->show_json('', 200, '操作成功');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user