187 lines
9.2 KiB
PHP
Executable File
187 lines
9.2 KiB
PHP
Executable File
<?php
|
|
defined('WXAPP_ITEMS') OR exit('No direct script access allowed');
|
|
ini_set('display_errors', 'On');
|
|
error_reporting(E_ERROR);
|
|
|
|
require_once APPPATH . 'controllers/wxapp/Wxapp.php';
|
|
|
|
/**
|
|
* Notes:分销团队
|
|
* Created on: 2020/6/29 15:16
|
|
* Created by: dengbw
|
|
*/
|
|
class Team extends Wxapp
|
|
{
|
|
private $uid;
|
|
|
|
function __construct($inputs, $app_key)
|
|
{
|
|
parent::__construct($inputs, $app_key);
|
|
$this->login_white = '';//
|
|
$this->check_status = array();//用户状态校验
|
|
$this->check_mobile = array();//需要手机号
|
|
$this->check_headimg = array();//授权微信信息
|
|
$this->majia_white = array('get');//超级管理员披上马甲可操作权限
|
|
|
|
$this->uid = $this->session['uid'];
|
|
$this->load->model('app/User_account_model', 'mdUserAccount');
|
|
$this->load->model('app/User_accountlog_model', 'mdUserAccountLog');
|
|
$this->load->model('app/Deal_log_model', 'mdDealLog');
|
|
}
|
|
|
|
/**
|
|
* Notes:顶部信息
|
|
* Created on: 2020/7/20 11:34
|
|
* Created by: dengbw
|
|
* @return mixed
|
|
* @throws Hd_exception
|
|
*/
|
|
protected function get_top()
|
|
{
|
|
$reU = $this->app_user_model->get(array('id' => $this->uid), 'id,dealer,up_uid');
|
|
if ($reU['dealer'] != 1) {
|
|
throw new Hd_exception('不是分销用户', API_CODE_FAIL);
|
|
}
|
|
if ($reU['dealer'] == 1 && $reU['up_uid'] == 0) {//一级分销
|
|
$up_uid = $reU['id'];
|
|
} else {//团员
|
|
$up_uid = $reU['up_uid'];
|
|
}
|
|
$img_url = $this->mdUserAccount->config()[$this->app_id]['deal']['img_url'];
|
|
$bg_color = $this->mdUserAccount->config()[$this->app_id]['deal']['bg_color'];
|
|
$total = $this->app_user_model->count(array('dealer' => 1, 'up_uid' => $up_uid));
|
|
$data['title'] = '分销团队';
|
|
$data['bg'] = array('color' => $bg_color, 'img' => $img_url . '/distribute/zc-bg.jpg');
|
|
$where = array('app_id' => $this->app_id, 'app_uid' => $up_uid, 'status' => 1, 'type in(1,3)' => null);
|
|
$sum = $this->mdDealLog->sum('money', $where);
|
|
$data['team_money'] = array('title' => '团队佣金(元)', 'value' => number_format_com($sum['money'], 2, ''));
|
|
$data['team_nums'] = array('title' => '团队人数', 'value' => $total);
|
|
$menulist[] = array('title' => '我', 'value' => 0);
|
|
$menulist[] = array('title' => '团员', 'value' => 1);
|
|
if ($this->app_config('lock_fans') == 1) {//锁粉才有粉丝
|
|
$menulist[] = array('title' => '粉丝', 'value' => 2);
|
|
}
|
|
$data['menulist'] = $menulist;
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* Notes:分销团队列表
|
|
* Created on: 2020/7/20 11:33
|
|
* Created by: dengbw
|
|
* @return mixed
|
|
* @throws Hd_exception
|
|
*/
|
|
protected function get()
|
|
{
|
|
$page = $this->input_param('page');
|
|
$size = $this->input_param('size');
|
|
$type = intval($this->input_param('type'));
|
|
!$page && $page = 1;
|
|
!$size && $size = 10;
|
|
$lists = $where = array();
|
|
$up_uid = 0;
|
|
$reU = $this->app_user_model->get(array('id' => $this->uid));
|
|
if ($reU['dealer'] != 1) {
|
|
throw new Hd_exception('不是分销用户', API_CODE_FAIL);
|
|
}
|
|
if ($type == 0) {
|
|
$myValue['nickname'] = $reU['nickname'] ? $reU['nickname'] : '我';
|
|
$myValue['orders'] = $this->mdDealLog->count(array('app_id' => $this->app_id, 'app_uid' => $this->uid, 'type in(0,2)' => null));
|
|
$myValue['orders_suc'] = $this->mdDealLog->count(array('app_id' => $this->app_id, 'app_uid' => $this->uid, 'type in(0,2)' => null, 'status' => 1));
|
|
$mySum = $this->mdDealLog->sum('money', array('app_id' => $this->app_id, 'app_uid' => $this->uid, 'type in(0,2)' => null, 'status' => 1));
|
|
$myValue['bring_money'] = number_format_com($mySum['money'], 2, '');
|
|
$lists[] = $myValue;
|
|
$data['field'] = array(array('title' => '姓名', 'value' => 'nickname'), array('title' => '订单数', 'value' => 'orders')
|
|
, array('title' => '成功数', 'value' => 'orders_suc'), array('title' => '带来佣金', 'value' => 'bring_money'));
|
|
$data['list'] = $lists;
|
|
$data['total'] = 1;
|
|
return $data;
|
|
} else if ($type == 1) {//团员
|
|
if ($reU['dealer'] == 1 && $reU['up_uid'] == 0) {//一级分销
|
|
$up_uid = $reU['id'];
|
|
} else {//团员
|
|
$up_uid = $reU['up_uid'];
|
|
}
|
|
$where = array('dealer' => 1, 'up_uid' => $up_uid);
|
|
$data['field'] = array(array('title' => '姓名', 'value' => 'nickname'), array('title' => '订单数', 'value' => 'orders')
|
|
, array('title' => '成功数', 'value' => 'orders_suc'), array('title' => '带来佣金', 'value' => 'bring_money'));
|
|
} else if ($type == 2) {//粉丝
|
|
$where = array('dealer' => 0, 'up_uid' => $this->uid);
|
|
$data['field'] = array(array('title' => '姓名', 'value' => 'nickname'),
|
|
array('title' => '订单数', 'value' => 'orders'), array('title' => '带来佣金', 'value' => 'bring_money'));
|
|
}
|
|
$resU = $this->app_user_model->select($where, 'id DESC', $page, $size, 'id,nickname');
|
|
$total = $this->app_user_model->count($where);
|
|
if ($total) {
|
|
foreach ($resU as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['nickname'] = $value['nickname'] ? $value['nickname'] : '神秘用户';
|
|
if ($type == 1) {
|
|
$where1 = array('app_id' => $this->app_id, 'app_uid' => $up_uid, 't_uid' => $value['id'], 'type in(1,3)' => null);
|
|
$where2 = array('app_id' => $this->app_id, 'app_uid' => $up_uid, 't_uid' => $value['id'], 'type in(1,3)' => null, 'status' => 1);
|
|
$orders = $this->mdDealLog->count($where1);
|
|
$orders_suc = $this->mdDealLog->count($where2);
|
|
$orders_suc > $orders && $orders = $orders_suc;
|
|
$setValue['orders'] = $orders;
|
|
$setValue['orders_suc'] = $orders_suc;
|
|
$sum = $this->mdDealLog->sum('money', $where2);
|
|
$setValue['bring_money'] = number_format_com($sum['money'], 2, '');
|
|
} else if ($type == 2) {
|
|
$where = array('app_id' => $this->app_id, 'app_uid' => $this->uid, 't_uid' => $value['id'], 'type' => 2, 'status' => 1);
|
|
$setValue['orders'] = $this->mdDealLog->count($where);
|
|
$sum = $this->mdDealLog->sum('money', $where);
|
|
$setValue['bring_money'] = number_format_com($sum['money'], 2, '');
|
|
}
|
|
$lists[] = $setValue;
|
|
}
|
|
}
|
|
$data['list'] = $lists;
|
|
$data['total'] = $total;
|
|
return $data;
|
|
}
|
|
|
|
protected function get_fans()
|
|
{
|
|
$page = $this->input_param('page');
|
|
$size = $this->input_param('size');
|
|
!$page && $page = 1;
|
|
!$size && $size = 10;
|
|
$lists = array();
|
|
$reU = $this->app_user_model->get(array('id' => $this->uid), 'id,dealer,up_uid');
|
|
if ($reU['dealer'] != 1) {
|
|
throw new Hd_exception('不是分销用户', API_CODE_FAIL);
|
|
}
|
|
$where = array('dealer' => 0, 'up_uid' => $this->uid);
|
|
$resU = $this->app_user_model->select($where, 'id DESC', $page, $size, 'id,nickname');
|
|
$total = $this->app_user_model->count($where);
|
|
if ($total) {
|
|
foreach ($resU as $key => $value) {
|
|
$setValue = array();
|
|
$setValue['nickname'] = $value['nickname'] ? $value['nickname'] : '神秘用户';
|
|
$where = array('app_id' => $this->app_id, 'app_uid' => $this->uid, 't_uid' => $value['id'], 'type' => 2, 'status' => 1);
|
|
$setValue['orders'] = $this->mdDealLog->count($where);
|
|
$sum = $this->mdDealLog->sum('money', $where);
|
|
$setValue['bring_money'] = number_format_com($sum['money'], 2, '');
|
|
$lists[] = $setValue;
|
|
}
|
|
}
|
|
if ($page == 1) {
|
|
$img_url = $this->mdUserAccount->config()[$this->app_id]['deal']['img_url'];
|
|
$bg_color = $this->mdUserAccount->config()[$this->app_id]['deal']['bg_color'];
|
|
$data['title'] = '分销粉丝';
|
|
$data['bg'] = array('color' => $bg_color, 'img' => $img_url . '/distribute/list-theme.jpg');
|
|
$where = array('app_id' => $this->app_id, 'app_uid' => $this->uid, 'type' => 2, 'status' => 1);
|
|
$sum = $this->mdDealLog->sum('money', $where);
|
|
$data['team_money'] = array('title' => '粉丝佣金(元)', 'value' => number_format_com($sum['money'], 2, ''));
|
|
$data['team_nums'] = array('title' => '粉丝人数', 'value' => $total);
|
|
$menulist[] = array('title' => '粉丝', 'value' => 1, 'field' => array(array('title' => '姓名', 'value' => 'nickname'),
|
|
array('title' => '订单数', 'value' => 'orders'), array('title' => '带来佣金', 'value' => 'bring_money')));
|
|
$data['menulist'] = $menulist;
|
|
}
|
|
$data['list'] = $lists;
|
|
$data['total'] = $total;
|
|
return $data;
|
|
}
|
|
}
|