edit-sylive-rank

This commit is contained in:
lccsw
2022-11-03 19:42:40 +08:00
parent 32d5c1a7dd
commit c6a0ce2407
8 changed files with 328 additions and 57 deletions
+72 -1
View File
@@ -335,5 +335,76 @@ class Syt extends CI_Controller
}
}
}
//更新活动用户表信息
public function tmp(){
$this->load->library('market/sylive_entity');
$this->load->model('market/market_sylive_user_model', 'user_model');
$this->load->model('market/market_sylive_activity_user_model', 'act_user_model');
$this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData');
$page = $this->input->get('page');
$size = $this->input->get('size');
!$page && $page = 1;
!$size && $size = 20;
$where = [
'organizationId>' => 0,
'userId>' => 0
];
$total = $this->act_user_model->count($where);
$filed = 'id,userId,activityId';
$rows = $this->act_user_model->select($where,'id asc',$page,$size,$filed);
if(!$rows){
echo "执行完毕";
}
$user_ids = implode(',',array_column($rows,'userId'));
$where = ["userId in ({$user_ids})"=>null];
$users = $this->user_model->map('userId','',$where);
foreach ($rows as $item) {
$user = $users[$item['userId']] ? $users[$item['userId']][0] : [];
if($user){
$update = [
'organizationId' => $user['organizationId'],
'teamId' => $user['teamId'],
];
if($update['organizationId']){
$level_lists = $this->sylive_entity->get_level_lists($update['organizationId']);
if($level_lists){
$area_id = $level_lists[1]['organizationId'];//获取大区id
$biz_id = $level_lists[2]['organizationId'];//获取店铺id
}
$type = 0;
}
if($update['teamId']){
$team_lists = $this->sylive_entity->get_team_lists($update['teamId']);
if($team_lists) {
$area_id = $team_lists[0]['teamId']; //大团长id
$biz_id = $team_lists[1]['teamId']; //团长id
}
$type = 1;
}
if($update['teamId']||$update['organizationId']){
$where = [
'type' => $type,
'activityId' => $item['activityId'],
'cfUserId' => $item['userId']
];
$where['kpi'] = 'browse';
$browse = $this->mdSytActivityKpiData->count($where);
$where['kpi'] = 'subscribe';
$subscribe = $this->mdSytActivityKpiData->count($where);
$where['kpi'] = 'order';
$orderTotal = $this->mdSytActivityKpiData->count($where);
$where['kpi'] = 'watch';
$watch = $this->mdSytActivityKpiData->count($where);
}
$area_id && $update['areaId'] = $area_id;
$biz_id && $update['bizId'] = $biz_id;
$browse && $update['browse'] = $browse;
$subscribe && $update['subscribe'] = $browse;
$orderTotal && $update['orderTotal'] = $browse;
$watch && $update['watch'] = $browse;
$this->act_user_model->update($update,['userId'=>$item['userId']]);
echo "更新成功:".json_encode($update,JSON_UNESCAPED_UNICODE)."<br>";
}
}
}
}