维护用户销售统计——筛选
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
* @Author: kangkang
|
* @Author: kangkang
|
||||||
* @Date: 2020-10-13 19:52:37
|
* @Date: 2020-10-13 19:52:37
|
||||||
* @LastEditors: Please set LastEditors
|
* @LastEditors: Please set LastEditors
|
||||||
* @LastEditTime: 2020-11-25 13:33:35
|
* @LastEditTime: 2020-11-25 16:41:06
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace app\manager\controller;
|
namespace app\manager\controller;
|
||||||
@@ -61,7 +61,6 @@ class UserFollow extends Controller
|
|||||||
if (!$manager_info['IsRoot']) {
|
if (!$manager_info['IsRoot']) {
|
||||||
$where['ManagerId'] = $this->userinfo['OperaterID'];
|
$where['ManagerId'] = $this->userinfo['OperaterID'];
|
||||||
$sort_where['ManagerId'] = $this->userinfo['OperaterID'];
|
$sort_where['ManagerId'] = $this->userinfo['OperaterID'];
|
||||||
$cost_where .= " ManagerId=" . $this->userinfo['OperaterID'] . ' ';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['PageIndex'])) {
|
if (isset($_GET['PageIndex'])) {
|
||||||
@@ -71,6 +70,7 @@ class UserFollow extends Controller
|
|||||||
$search = $_GET['search'];
|
$search = $_GET['search'];
|
||||||
if (!empty($search['profile'])) {
|
if (!empty($search['profile'])) {
|
||||||
$where['follow_status'] = $search['profile'];
|
$where['follow_status'] = $search['profile'];
|
||||||
|
$sort_where['follow_status'] = $search['profile'];
|
||||||
}
|
}
|
||||||
if (!empty($search['keyWord'])) {
|
if (!empty($search['keyWord'])) {
|
||||||
$where['LoginCode'] = ['like', '%' . $search['keyWord'] . '%'];
|
$where['LoginCode'] = ['like', '%' . $search['keyWord'] . '%'];
|
||||||
@@ -93,11 +93,11 @@ class UserFollow extends Controller
|
|||||||
//本月
|
//本月
|
||||||
$time_where2 .= " UpdateTime>='" . $date3 . "' and UpdateTime<='" . $date4 . "' ";
|
$time_where2 .= " UpdateTime>='" . $date3 . "' and UpdateTime<='" . $date4 . "' ";
|
||||||
|
|
||||||
if (!empty($search['money1'])) {
|
if (!empty($search['money2'])) {
|
||||||
$is_screen = true;
|
$is_screen = true;
|
||||||
switch ($search['cost_type']) {
|
switch ($search['cost_type']) {
|
||||||
case 0:
|
case 0:
|
||||||
$time_where3 = '';
|
$time_where3 .= '';
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$time_where3 .= " product_order.UpdateTime>='" . $date1 . "' and product_order.UpdateTime<='" . $date2 . "' ";
|
$time_where3 .= " product_order.UpdateTime>='" . $date1 . "' and product_order.UpdateTime<='" . $date2 . "' ";
|
||||||
@@ -107,7 +107,9 @@ class UserFollow extends Controller
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$cost_where .= "having money >=" . $search['money1'] . " and money <=" . $search['money2'] . ' ';
|
$cost_where .= "having money >=" . $search['money1'] . " and money <=" . $search['money2'] . ' ';
|
||||||
$user_search_id = $product_order_model->getScreenCost($time_where3, $cost_where, "$page,50");
|
if (empty($search['sortLable'])) {
|
||||||
|
$user_search_id = $product_order_model->getScreenCost($time_where3, $cost_where, "$page,50", $sort_where);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!empty($search['sortLable'])) {
|
if (!empty($search['sortLable'])) {
|
||||||
$is_screen = true;
|
$is_screen = true;
|
||||||
@@ -115,13 +117,13 @@ class UserFollow extends Controller
|
|||||||
$time_where_now .= " product_order.UpdateTime>='" . $date3 . "' and product_order.UpdateTime<='" . $date4 . "' ";
|
$time_where_now .= " product_order.UpdateTime>='" . $date3 . "' and product_order.UpdateTime<='" . $date4 . "' ";
|
||||||
switch ($search['sortLable']) {
|
switch ($search['sortLable']) {
|
||||||
case 'all_amount':
|
case 'all_amount':
|
||||||
$user_search_id = $product_order_model->getSort($sort_where, $search['sortOrder'], "$page,50");
|
$user_search_id = $product_order_model->getSort($sort_where, $search['sortOrder'], "$page,50", $time_where3, $cost_where);
|
||||||
break;
|
break;
|
||||||
case 'PrevMonthAmount':
|
case 'PrevMonthAmount':
|
||||||
$user_search_id = $product_order_model->getMonthSort($sort_where, $search['sortOrder'], "$page,50", $time_where_pre);
|
$user_search_id = $product_order_model->getMonthSort($sort_where, $search['sortOrder'], "$page,50", $time_where_pre, $cost_where);
|
||||||
break;
|
break;
|
||||||
case 'MonthAmount':
|
case 'MonthAmount':
|
||||||
$user_search_id = $product_order_model->getMonthSort($sort_where, $search['sortOrder'], "$page,50", $time_where_now);
|
$user_search_id = $product_order_model->getMonthSort($sort_where, $search['sortOrder'], "$page,50", $time_where_now, $cost_where);
|
||||||
break;
|
break;
|
||||||
case 'account_count':
|
case 'account_count':
|
||||||
$user_search_id = $product_account_model->getSort($sort_where, $search['sortOrder'], "$page,50", 1);
|
$user_search_id = $product_account_model->getSort($sort_where, $search['sortOrder'], "$page,50", 1);
|
||||||
@@ -151,7 +153,7 @@ class UserFollow extends Controller
|
|||||||
}
|
}
|
||||||
$where['Id'] = ['in', $user_search_id_list];
|
$where['Id'] = ['in', $user_search_id_list];
|
||||||
}
|
}
|
||||||
if(empty($user_search_id_list)){
|
if (empty($user_search_id_list)) {
|
||||||
$limit = "$page,50";
|
$limit = "$page,50";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* @Author: kangkang
|
* @Author: kangkang
|
||||||
* @Date: 2020-10-16 14:44:02
|
* @Date: 2020-10-16 14:44:02
|
||||||
* @LastEditors: Please set LastEditors
|
* @LastEditors: Please set LastEditors
|
||||||
* @LastEditTime: 2020-11-25 13:27:34
|
* @LastEditTime: 2020-11-25 16:40:37
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace app\manager\model;
|
namespace app\manager\model;
|
||||||
@@ -38,7 +38,7 @@ class ProductOrder extends Model
|
|||||||
*/
|
*/
|
||||||
public function getAllMoney($where = '', $where2 = [])
|
public function getAllMoney($where = '', $where2 = [])
|
||||||
{
|
{
|
||||||
$data = $this->field('sum(PaymentAmount) as money,UserId')
|
$data = $this->field('sum(PaymentAmount) as money,UserId')
|
||||||
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
|
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
|
||||||
->where($where)
|
->where($where)
|
||||||
->where($where2)
|
->where($where2)
|
||||||
@@ -46,11 +46,11 @@ class ProductOrder extends Model
|
|||||||
->fetchAll();
|
->fetchAll();
|
||||||
$result = [
|
$result = [
|
||||||
'money' => 0,
|
'money' => 0,
|
||||||
'num' => 0
|
'num' => 0,
|
||||||
];
|
];
|
||||||
foreach($data as $info){
|
foreach ($data as $info) {
|
||||||
$result['money'] += $info['money'];
|
$result['money'] += $info['money'];
|
||||||
$result['num'] ++;
|
$result['num']++;
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -151,17 +151,18 @@ class ProductOrder extends Model
|
|||||||
* @param {*}
|
* @param {*}
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
public function getSort($where = [],$order = 1, $limit = '50')
|
public function getSort($where = [], $order = 1, $limit = '50', $time_where, $having = '')
|
||||||
{
|
{
|
||||||
$order_type = 'money';
|
$order_type = 'money';
|
||||||
if($order == '0'){
|
if ($order == '0') {
|
||||||
$order_type = 'money desc';
|
$order_type = 'money desc';
|
||||||
}
|
}
|
||||||
return $this->field('product_order.UserId,sum(product_order.PaymentAmount) as money')
|
return $this->field('product_order.UserId,sum(product_order.PaymentAmount) as money')
|
||||||
->join('user ON product_order.UserId=user.Id')
|
->join('user ON product_order.UserId=user.Id')
|
||||||
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
|
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
|
||||||
|
->where($time_where)
|
||||||
->where($where)
|
->where($where)
|
||||||
->group(['product_order.UserId'])
|
->group(['product_order.UserId'], $having)
|
||||||
->order($order_type)
|
->order($order_type)
|
||||||
->limit($limit)
|
->limit($limit)
|
||||||
->fetchAll();
|
->fetchAll();
|
||||||
@@ -172,10 +173,10 @@ class ProductOrder extends Model
|
|||||||
* @param {*} flag = true 上一个月
|
* @param {*} flag = true 上一个月
|
||||||
* @return {*} flag = false 本月
|
* @return {*} flag = false 本月
|
||||||
*/
|
*/
|
||||||
public function getMonthSort($where = [],$order = 1, $limit = '50', $where2 ='')
|
public function getMonthSort($where = [], $order = 1, $limit = '50', $where2 = '', $having = '')
|
||||||
{
|
{
|
||||||
$order_type = 'money';
|
$order_type = 'money';
|
||||||
if($order == '0'){
|
if ($order == '0') {
|
||||||
$order_type = 'money desc';
|
$order_type = 'money desc';
|
||||||
}
|
}
|
||||||
return $this->field('product_order.UserId,sum(product_order.PaymentAmount) as money')
|
return $this->field('product_order.UserId,sum(product_order.PaymentAmount) as money')
|
||||||
@@ -183,7 +184,7 @@ class ProductOrder extends Model
|
|||||||
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
|
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
|
||||||
->where($where)
|
->where($where)
|
||||||
->where($where2)
|
->where($where2)
|
||||||
->group(['product_order.UserId'])
|
->group(['product_order.UserId'], $having)
|
||||||
->order($order_type)
|
->order($order_type)
|
||||||
->limit($limit)
|
->limit($limit)
|
||||||
->fetchAll();
|
->fetchAll();
|
||||||
@@ -194,13 +195,14 @@ class ProductOrder extends Model
|
|||||||
* @param {*}
|
* @param {*}
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
public function getScreenCost($where,$having, $limit = '50')
|
public function getScreenCost($where, $having, $limit = '50', $where2 = [])
|
||||||
{
|
{
|
||||||
return $this->field('UserId,sum(PaymentAmount) as money')
|
return $this->field('UserId,sum(PaymentAmount) as money')
|
||||||
->join('user ON product_order.UserId=user.Id')
|
->join('user ON product_order.UserId=user.Id')
|
||||||
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
|
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
|
||||||
->where($where)
|
->where($where)
|
||||||
->group(['UserId'],$having)
|
->where($where2)
|
||||||
|
->group(['UserId'], $having)
|
||||||
->fetchAll();
|
->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +211,7 @@ class ProductOrder extends Model
|
|||||||
* @param {*}
|
* @param {*}
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
public function getUserCost($user_id, $index, $where='')
|
public function getUserCost($user_id, $index, $where = '')
|
||||||
{
|
{
|
||||||
return $this->field('UpdateTime,OrderNo,OrderType,ProductName,PackageName,PaymentAmount,Accounts,ConnectCount,PayType')
|
return $this->field('UpdateTime,OrderNo,OrderType,ProductName,PackageName,PaymentAmount,Accounts,ConnectCount,PayType')
|
||||||
->where(['UserId' => $user_id])
|
->where(['UserId' => $user_id])
|
||||||
|
|||||||
Reference in New Issue
Block a user