fix-sylive-add-order

This commit is contained in:
lccsw
2022-11-11 13:19:48 +08:00
parent 3d0fab681d
commit d2c0f24ccc
7 changed files with 130 additions and 26 deletions
+52
View File
@@ -538,4 +538,56 @@ class Syt extends CI_Controller
echo '更新完毕';
}
}
public function order_info(){
$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_order_model','order_model');
$this->load->model('market/market_sylive_activity_model');
$this->load->model('market/market_sylive_activity_orders_model','mdSytActivityOrders');
$this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData');
$this->load->library('market/sylive_entity');
$page = $this->input->get('page');
$size = $this->input->get('size');
!$page && $page = 1;
!$size && $size = 20;
$where = [
'activityId' => 4,
'status' => 1,
'bizId' => 0,
'areaId' => 0,
];
$rows = $this->order_model->select($where,'id asc',$page,$size);
if($rows){
foreach ($rows as $item) {
$user = $this->user_model->get(['userId'=>$item['userId']]);
$act_user = $this->act_user_model->get(['userId'=>$item['userId'],'activityId'=>$item['activityId']]);
$p_user = [];
$act_user['channelId'] && $p_user = $this->act_user_model->get(['userId'=>$act_user['channelId']]);
if(!$p_user){
if($user['teamId']){ //团长
$t_level_id = $this->sylive_entity->get_team_level($user['teamId']);
$p_user = $t_level_id<3 ? $act_user : [];
}
if($user['organizationId']){ //顾问
$group_id = $this->sylive_entity->get_level($user['organizationId']);
$p_user = $group_id<4 ? $act_user : 0;
}
}
$update = [];
$p_user['teamId'] && $update['cfrom'] = 1;
$p_user['areaId'] && $update['areaId'] = $p_user['areaId'];
$p_user['bizId'] && $update['bizId'] = $p_user['bizId'];
$p_user['userId'] && $update['cfUserId'] = $p_user['userId'];
if($update){
echo "订单id:{$item['id']},更新:".json_encode($update,JSON_UNESCAPED_UNICODE).'<br>';
$this->order_model->update($update,['id'=>$item['id']]);
}else{
echo "订单id:{$item['id']},不存在上级<br>";
}
}
}else{
echo '更新完毕';
}
}
}
+17 -10
View File
@@ -88,6 +88,7 @@ class Sylive_data_entity{
if($biz_ids){
$org_rows = $this->ci->market_sylive_organization_model->map('organizationId','',["organizationId in ($biz_ids)"=>null],'','','','organizationId,organizationName');
}
$num_tip = $params['kpi'] == 'order' ? '单' : '人';
$start = $page>1 ? ($page-1)*$size : 0;
foreach ($rows as $key=>$val) {
$name = $tip = '';
@@ -109,7 +110,7 @@ class Sylive_data_entity{
$lists[] = [
'ranking' => $start+$key+1,
'name' => $name,
'num' => $val['t'].'人',
'num' => $val['t'].$num_tip,
'tip' => $tip,
];
}
@@ -138,11 +139,12 @@ class Sylive_data_entity{
$org_rows = $this->ci->market_sylive_organization_model->map('organizationId','organizationName',["organizationId in ($biz_ids)"],'','','','organizationId,organizationName');
}
$start = $page>1 ? ($page-1)*$size : 0;
$num_tip = $type == 'order' ? '单' : '人';
foreach ($rows as $key=>$val) {
$lists[] = [
'ranking' => $start+$key+1,
'name' => $org_rows[$val['bizId']] ? $org_rows[$val['bizId']] : '',
'num' => $val[$this->map_kpi_biz[$type]].'人',
'num' => $val[$this->map_kpi_biz[$type]].$num_tip,
'tip' => $biz_id==$val['bizId'] ? '本店' : '',
];
}
@@ -182,11 +184,12 @@ class Sylive_data_entity{
$org_rows = $this->ci->market_sylive_organization_model->map('organizationId','organizationName',["organizationId in ($area_ids)"=>null],'','','','organizationId,organizationName');
}
$start = $page>1 ? ($page-1)*$size : 0;
$num_tip = $type == 'order' ? '单' : '人';
foreach ($rows as $key=>$val) {
$lists[] = [
'ranking' => $start+$key+1,
'name' => $org_rows[$val['areaId']] ? $org_rows[$val['areaId']] : '',
'num' => $val['t'].'人',
'num' => $val['t'].$num_tip,
'tip' => '',
];
}
@@ -217,6 +220,7 @@ class Sylive_data_entity{
$area_ids = implode(',',array_column($rows,'areaId'));
$org_rows = $this->ci->market_sylive_organization_model->map('organizationId','',["organizationId in ($area_ids)"=>null],'','','','organizationId,organizationName');
$start = $page>1 ? ($page-1)*$size : 0;
$num_tip = $params['kpi'] == 'order' ? '单' : '人';
foreach ($rows as $key=>$val) {
$where = [
'areaId' => $val['areaId'],
@@ -226,14 +230,14 @@ class Sylive_data_entity{
if($params['createTime']){
$where['day='] = date('Y-m-d',strtotime($params['createTime']));
}
$params['kpi'] = $where['kpi'] = $params['kpi'];
$where['kpi'] = $params['kpi'];
$total = $this->ci->mdSytActivityKpiData->count($where);
$org = $org_rows[$val['areaId']] ? $org_rows[$val['areaId']][0] : [];
$lists[] = [
'ranking' => $start+$key+1,
'name' => $org ? $org['organizationName'] : '',
'total' => $total,
'num' => $total.'人',
'num' => $total.$num_tip,
'tip' => '',
];
}
@@ -281,6 +285,7 @@ class Sylive_data_entity{
$biz_rows = $this->ci->market_sylive_organization_model->map('organizationId','',["organizationId in ($biz_ids)"=>null],'','','','organizationId,organizationName');
}
$start = $page>1 ? ($page-1)*$size : 0;
$num_tip = $type == 'order' ? '单' : '人';
foreach ($rows as $key=>$val) {
$user = $user_rows[$val['userId']] ? $user_rows[$val['userId']][0] : [];
$biz = $biz_rows[$val['bizId']] ? $biz_rows[$val['bizId']][0] : [];
@@ -288,7 +293,7 @@ class Sylive_data_entity{
$lists[] = [
'ranking' => $start+$key+1,
'name' => $user['uname'].$biz_name,
'num' => $val['t'].'人',
'num' => $val['t'].$num_tip,
'tip' => $userId==$val['userId'] ? '本人' : '',
'headimg' => $user['headimg']
];
@@ -318,12 +323,13 @@ class Sylive_data_entity{
if($team_ids){
$org_rows = $this->ci->market_sylive_team_model->map('teamId','teamName',["teamId in ($team_ids)"=>null],'','','','teamId,teamName');
}
$num_tip = $type == 'order' ? '单' : '人';
$start = $page>1 ? ($page-1)*$size : 0;
foreach ($rows as $key=>$val) {
$lists[] = [
'ranking' => $start+$key+1,
'name' => $org_rows[$val['teamId2']] ? $org_rows[$val['teamId2']] : '',
'num' => $val[$this->map_kpi_biz[$type]].'人',
'num' => $val[$this->map_kpi_biz[$type]].$num_tip,
'tip' => $teamId==$val['teamId2'] ? '我的团队' : '',
];
}
@@ -363,6 +369,7 @@ class Sylive_data_entity{
if($user_ids){
$user_rows = $this->ci->user_model->map('userId','',["userId in ($user_ids)"=>null],'','','','userId,uname,nickname,headimg');
}
$num_tip = $type == 'order' ? '单' : '人';
$start = $page>1 ? ($page-1)*$size : 0;
foreach ($rows as $key=>$val) {
$user = $user_rows[$val['userId']] ? $user_rows[$val['userId']][0] : [];
@@ -373,7 +380,7 @@ class Sylive_data_entity{
'name' => name_asterisk($name),
'headimg' => self::DF_IMG,
'total' => $val['t'],
'num' => $val['t'].'人',
'num' => $val['t'].$num_tip,
'tip' => $userId==$val['userId'] ? '本人' : '',
];
}
@@ -405,7 +412,7 @@ class Sylive_data_entity{
$org_rows = $this->ci->market_sylive_team_model->map('teamId','',["teamId in ($team_ids)"=>null],'','','','teamId,teamName as name');
}
}
$num_tip = $where['kpi'] == 'order' ? '单' : '人';
$start = $page>1 ? ($page-1)*$page_size : 0;
foreach ($rows as $key=>$val) {
if($groupby=='cfUserId'){
@@ -418,7 +425,7 @@ class Sylive_data_entity{
$lists[] = [
'ranking' => $start+$key+1,
'name' => $org['name'],
'num' => $val['t'].'人',
'num' => $val['t'].$num_tip,
'tip' => $tip,
];
}
+4 -3
View File
@@ -270,14 +270,15 @@ class Sylive_entity{
$map[$item['cf_uid']] = null !== $item['total'] ? $item['total'] : $item;
}
}
$num_tip = $type == 'order' ? '单' : '人';
foreach ($rows as $item) {
$total = $map[$item['userId']] ? $map[$item['userId']] : '0';
$lists[] = [
'uid' => $item['userId'],
'name' => $item['uname'] ? $item['uname'] : $item['nickname'],
'headimg' => $item['headimg'] ? $item['headimg'] : self::DEFAULT_HEAD,
'total' => $total,
'num' => "{$total}",
'total' => $num,
'num' => "{$num}{$num_tip}",
'tip' => $uid == $item['userId'] ? '本人' : '',
];
}
@@ -514,4 +515,4 @@ class Sylive_entity{
}
return null;
}
}
}
+11 -1
View File
@@ -141,9 +141,20 @@ class Item extends Wx{
if($row['stock']<=0){
$this->show_json('',400,'已售罄');
}
$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']]);
if(!$p_user){
if($user['teamId']){ //团长
$t_level_id = $this->sylive_entity->get_team_level($user['teamId']);
$p_user = $t_level_id<3 ? $act_user : [];
}
if($user['organizationId']){ //顾问
$group_id = $this->sylive_entity->get_level($user['organizationId']);
$p_user = $group_id<4 ? $act_user : 0;
}
}
$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); //获取集合中用户数量
@@ -205,7 +216,6 @@ class Item extends Wx{
}
$this->market_sylive_order_model->update($update,['id'=>$unpay['id']]);
}
$user = $this->user_model->get(['userId'=>$this->uid]);
$notify_url = http_host_com('home').'/h5/market/sylive/notify/item';
$result = $this->unorder($unpay['sid'],$unpay['totalPrice'],$user['openid'],$unpay['itemTitle'],$notify_url,$unpay['expireTime'],['wx_type'=>'dc']);
if(!$result['code']){
+19 -6
View File
@@ -12,6 +12,7 @@ class Stic extends Admin{
$this->load->model('market/market_sylive_activity_biz_model','mdSytActivityBiz');
$this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData');
$this->load->model('market/market_sylive_order_model');
$this->load->model('market/market_sylive_items_model');
$this->load->model('live/Live_polyv_session_model', 'mdPolyvSession');
$this->load->library('market/sylive_entity');
$this->load->library('market/sylive_data_entity');
@@ -46,7 +47,7 @@ class Stic extends Admin{
$order_count = $this->mdSytActivityKpiData->count(['activityId'=>$a_id,'kpi'=>'order','cfUserId'=>$this->uid,'type'=>0]);
$info['live'] = [
['title' => '观看用户', 'num' => "{$watch_count}",'url' => '/h5/market/sylive/stic/users?type=owner&kpi=watch&a_id='.$a_id],
['title' => '下单用户', 'num' => "{$order_count}",'url' => '/h5/market/sylive/stic/users?type=owner&kpi=order&a_id='.$a_id],
['title' => '下单', 'num' => "{$order_count}",'url' => '/h5/market/sylive/stic/users?type=owner&kpi=order&a_id='.$a_id],
['title' => '转化率', 'num' => $watch_count ? round($order_count/$watch_count*100,2)."%" : 0],
];
$this->data['info'] = $info;
@@ -256,7 +257,7 @@ class Stic extends Admin{
$all_order_count = $this->mdSytActivityKpiData->count($where); //下单数据
$all = [
['title' => '观看用户', 'num' => "{$all_view_count}",'url'=>''],
['title' => '下单用户', 'num' => "{$all_order_count}",'url'=>''],
['title' => '下单', 'num' => "{$all_order_count}",'url'=>''],
['title' => '转化率', 'num' => $all_view_count ? round($all_order_count/$all_view_count*100,2)."%" : 0],
];
}else{
@@ -274,7 +275,7 @@ class Stic extends Admin{
$a_order_count = $this->mdSytActivityKpiData->count($where); //下单数据
$area = [
['title' => '观看用户', 'num' => "{$a_view_count}",'url'=>""],
['title' => '下单用户', 'num' => "{$a_order_count}",'url'=>""],
['title' => '下单', 'num' => "{$a_order_count}",'url'=>""],
['title' => '转化率', 'num' => $a_view_count ? round($a_order_count/$a_view_count*100,2)."%" : 0],
];
}
@@ -317,7 +318,7 @@ class Stic extends Admin{
$m_order_count = $this->mdSytActivityKpiData->count($where); //下单数据
$mine = [
['title' => '观看用户', 'num' => "{$m_view_count}",'url'=>'/h5/market/sylive/stic/users?type=owner&kpi=watch&a_id='.$a_id],
['title' => '下单用户', 'num' => "{$m_order_count}",'url'=>'/h5/market/sylive/stic/users?type=owner&kpi=order&a_id='.$a_id],
['title' => '下单', 'num' => "{$m_order_count}",'url'=>'/h5/market/sylive/stic/users?type=owner&kpi=order&a_id='.$a_id],
['title' => '转化率', 'num' => $m_view_count ? round($m_order_count/$m_view_count*100,2)."%" : 0],
];
if($biz_id){
@@ -332,7 +333,7 @@ class Stic extends Admin{
$b_order_count = $this->mdSytActivityKpiData->count($where); //下单数据
$biz = [
['title' => '观看用户', 'num' => "{$b_view_count}",'url'=>"/h5/market/sylive/stic/users?type=biz&type_id={$biz_id}&kpi=watch&a_id={$a_id}"],
['title' => '下单用户', 'num' => "{$b_order_count}",'url'=>"/h5/market/sylive/stic/users?type=biz&type_id={$biz_id}&kpi=order&a_id={$a_id}"],
['title' => '下单', 'num' => "{$b_order_count}",'url'=>"/h5/market/sylive/stic/users?type=biz&type_id={$biz_id}&kpi=order&a_id={$a_id}"],
['title' => '转化率', 'num' => $b_view_count ? round($b_order_count/$b_view_count*100,2)."%" : 0],
];
}
@@ -599,7 +600,7 @@ class Stic extends Admin{
public function users(){
$map_kpi_name = [
'browse' => '访问用户', 'subscribe' => '预约用户', 'order' => '下单用户','watch' => '观看用户'
'browse' => '访问用户', 'subscribe' => '预约用户', 'order' => '下单','watch' => '观看用户'
];
$params = $this->input->get();
$a_id = intval($params['a_id']);//活动id
@@ -614,9 +615,18 @@ class Stic extends Admin{
if($this->group_id==2 || ($params['type']=='biz'&&$params['type_id'])){ //店长
$tab[] = ['id'=>2,'title'=>'顾问数据'];
}
$goods = [];
if($params['kpi']=='order'){
$where = [
'activityId' => $a_id,
'status' => 0
];
$goods = $this->market_sylive_items_model->select($where,'sort desc,itemId desc',0,0,'itemId,title');
}
$this->data['title'] = $title;
$this->data['tab'] = $tab;
$this->data['params'] = $params;
$this->data['goods'] = $goods;
//微信分享
$wx_info = $this->share_info($row);
$this->data['sign_package'] = $wx_info['sign_package'];
@@ -644,6 +654,9 @@ class Stic extends Admin{
}else{
$where['cfUserId'] = $this->uid;
}
if($params['kpi']=='order' && $params['itemId']){
$where["tagId in (select id from lc_market_sylive_order where itemId={$params['itemId']} and activityId={$params['a_id']})"] = null;
}
$total = $this->mdSytActivityKpiData->count($where);
$lists = [];
if($total){
+4 -4
View File
@@ -47,7 +47,7 @@ class Tstic extends Admin{
$order_count = $this->mdSytActivityKpiData->count(['activityId'=>$a_id,'kpi'=>'order','cfUserId'=>$this->uid,'type'=>1]);
$info['live'] = [
['title' => '观看用户', 'num' => "{$watch_count}",'url' => '/h5/market/sylive/tstic/users?type=owner&kpi=watch&a_id='.$a_id],
['title' => '下单用户', 'num' => "{$order_count}",'url' => '/h5/market/sylive/tstic/users?type=owner&kpi=order&a_id='.$a_id],
['title' => '下单', 'num' => "{$order_count}",'url' => '/h5/market/sylive/tstic/users?type=owner&kpi=order&a_id='.$a_id],
['title' => '转化率', 'num' => $watch_count ? round($order_count/$watch_count*100,2)."%" : 0],
];
$this->data['info'] = $info;
@@ -229,13 +229,13 @@ class Tstic extends Admin{
$owner_order_count = $this->mdSytActivityKpiData->count($where); //下单数据
$cell4 = [
['title' => '观看用户', 'num' => "{$owner_view_count}",'url'=>'/h5/market/sylive/tstic/users?type=owner&kpi=watch&a_id='.$a_id],
['title' => '下单用户', 'num' => "{$owner_order_count}",'url'=>'/h5/market/sylive/tstic/users?type=owner&kpi=order&a_id='.$a_id],
['title' => '下单', 'num' => "{$owner_order_count}",'url'=>'/h5/market/sylive/tstic/users?type=owner&kpi=order&a_id='.$a_id],
['title' => '转化率', 'num' => $owner_view_count ? round($owner_order_count/$owner_view_count*100,2)."%" : 0],
];
}
$cell1 = [
['title' => '观看用户', 'num' => "{$view_count}",'url'=>'/h5/market/sylive/tstic/users?type=all&kpi=watch&a_id='.$a_id],
['title' => '下单用户', 'num' => "{$order_count}",'url'=>'/h5/market/sylive/tstic/users?type=all&kpi=order&a_id='.$a_id],
['title' => '下单', 'num' => "{$order_count}",'url'=>'/h5/market/sylive/tstic/users?type=all&kpi=order&a_id='.$a_id],
['title' => '转化率', 'num' => $view_count ? round($order_count/$view_count*100,2)."%" : 0],
];
$poly_row = $this->mdPolyvSession->get(['channelId'=>$row['channelId']]);
@@ -464,7 +464,7 @@ class Tstic extends Admin{
public function users(){
$map_kpi_name = [
'browse' => '访问用户', 'subscribe' => '预约用户', 'order' => '下单用户','watch' => '观看用户'
'browse' => '访问用户', 'subscribe' => '预约用户', 'order' => '下单','watch' => '观看用户'
];
$params = $this->input->get();
$a_id = intval($params['a_id']);//活动id
+23 -2
View File
@@ -17,6 +17,12 @@
<div class="fn-flex-item" v-for="(item,index) in tab"><a :class="'relative inline-block tab-menu '+ [tabid == item.id?'font-36 active':'font-32']" @click="changeTab(item.id,index)" href="javascript:">{{item.title}}</a></div>
<div :class="'glider glider-'+tabIndex"></div>
</div>
<div class="pt30" v-if="kpi=='order' && goodsList">
<select class="wp100 select-more ulib-r10 font-28" @change="changegoods">
<option value="">全部</option>
<option :value="item.itemId" v-for="item in goodsList">{{item.title}}</option>
</select>
</div>
</template>
<template v-else>
<div class="pt10 pb20 text-center"><b class="font-40 text-italic" v-html="title"></b></div>
@@ -72,6 +78,9 @@
size: 20, //每页取多少个数据
title:'<?=$title?>',
list:[],
kpi:'<?=$params['kpi']?>',
goodsList: <?=json_encode($goods,JSON_UNESCAPED_UNICODE)?>,
goodsId:'',
},
created(){
@@ -128,7 +137,7 @@
if (!that.isNoData && !that.isDataEnd && !that.loading) {
that.loading = true;
//请求接口
$.get('/h5/market/sylive/stic/user_lists',{'a_id':'<?=$params['a_id']?>','type':'<?=$params['type']?>','type_id':'<?=$params['type_id']?>','kpi':'<?=$params['kpi']?>','page':that.page,'tabid':that.tabid},function (res){
$.get('/h5/market/sylive/stic/user_lists',{'a_id':'<?=$params['a_id']?>','type':'<?=$params['type']?>','type_id':'<?=$params['type_id']?>','kpi':'<?=$params['kpi']?>','page':that.page,'tabid':that.tabid,'itemId':that.goodsId},function (res){
that.loading = false;
that.page = that.page + 1;
@@ -141,8 +150,20 @@
},'json');
}
},
//选择日期
changegoods(e){
if(this.goodsId != e.target.value){;
this.goodsId = e.target.value
this.loading = false;
this.isDataEnd = false;
this.isNoData = false;
this.page = 1;
this.list = [];
this.getActivityList()
}
},
},
})
</script>
<?=$this->load->view('h5/market/sylive/share_script')?>
</body>
</body>