消费统计界面基础表格和搜索

This commit is contained in:
wanyongkang
2020-11-20 16:02:54 +08:00
parent deb09ebb2f
commit 1b9e56b24a
8 changed files with 670 additions and 26 deletions

View File

@@ -0,0 +1,23 @@
<?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-16 14:44:02
* @LastEditors: kangkang
* @LastEditTime: 2020-11-18 16:42:07
*/
namespace app\manager\model;
use fastphp\base\Model;
class FollowRecord extends Model
{
protected $table = 'follow_record';
public function getNewRecord($where)
{
return $this->where($where)->order()->limit('3')->fetchAll();
}
}

View File

@@ -0,0 +1,91 @@
<?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-16 14:44:02
* @LastEditors: kangkang
* @LastEditTime: 2020-11-20 10:31:38
*/
namespace app\manager\model;
use fastphp\base\Model;
use enum\account\ProductAccount as ProductAccountEnum;
class ProductAccount extends Model
{
protected $table = 'product_account';
/**
* @description: 获取使用中和已经过期额的帐号
* @param {*}
* @return {*}
*/
public function getUesdAccount($where = [])
{
return $this->field('UserId, sum(ConnectCount) used_count')->where($where)->group(['UserId'])->fetchAll();
}
/**
* @description: 获取用户帐号信息
* @param {*}
* @return {*}
*/
public function getUserAccount($user_id, $index)
{
$product_account_enum = new ProductAccountEnum;
$where = [];
$wheres = [];
switch($index){
case 1:
$where = ['DeleteTag' => 0, 'AccountType' => ['<>', $product_account_enum::$Test]];
break;
case 2:
$where = ['DeleteTag' => 0, 'EndTime' => ['>', date('Y-m-d H:i:s')], 'AccountType' => ['<>', $product_account_enum::$Test]];
break;
case 3:
$where = ['DeleteTag' => 0, 'EndTime' => ['<=', date('Y-m-d H:i:s')], 'AccountType' => ['<>', $product_account_enum::$Test]];
break;
}
return $this->field('ProductName,PackageName,Account,StartTime,EndTime,UpdateTime')
->where(['UserId' => $user_id])
->where($where)
->order('Id desc')
->fetchAll();
}
/**
* @description: 按照排序条件进行查询
* @param {*}
* @return {*}
*/
public function getSort($where = [],$order = 1, $limit = '50',$index)
{
$order_type = 'account_count';
if($order == '0'){
$order_type = 'account_count desc';
}
$product_account_enum = new ProductAccountEnum;
$wheres = [];
switch($index){
case 1:
$wheres = "product_account.DeleteTag=0 and AccountType<>".$product_account_enum::$Test;
break;
case 2:
$wheres = "product_account.DeleteTag=0 and AccountType<>".$product_account_enum::$Test." and product_account.EndTime>'".date('Y-m-d H:i:s')."'";
break;
case 3:
$wheres = "product_account.DeleteTag=0 and AccountType<>".$product_account_enum::$Test." and product_account.EndTime<='".date('Y-m-d H:i:s')."'";
break;
}
return $this->field('product_account.UserId,sum(product_account.ConnectCount) account_count')
->join('user ON product_account.UserId=user.Id')
->where($where)
->where($wheres)
->group(['product_account.UserId'])
->order($order_type)
->limit($limit)
->fetchAll();
}
}

View File

@@ -1,17 +1,17 @@
<?php
/*
* @Descripttion:
* @version:
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-16 14:44:02
* @LastEditors: kangkang
* @LastEditTime: 2020-11-16 16:22:02
* @LastEditTime: 2020-11-19 18:49:23
*/
namespace app\manager\model;
use fastphp\base\Model;
use enum\order\ProductOrder as ProductOrderEnum;
use fastphp\base\Model;
class ProductOrder extends Model
{
@@ -22,12 +22,13 @@ class ProductOrder extends Model
* @param {*}
* @return {*}
*/
public function getCost(){
public function getCost()
{
return $this->field('UserId,sum(PaymentAmount) as money')
->where(['OrderState'=>['in',ProductOrderEnum::$PayComplete]])
->group(['UserId'])
->order('money')
->fetchAll();
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
->group(['UserId'])
->order('money')
->fetchAll();
}
/**
@@ -35,30 +36,141 @@ class ProductOrder extends Model
* @param {*}
* @return {*}
*/
public function getMonthCost($user_id){
public function getMonthCost($user_id)
{
$last_month = date("Y-m-d H:i:s", strtotime("-1 month"));
$new_month = date("Y-m-d H:i:s", time());
return $this->field('UserId,sum(PaymentAmount) as money')
->where(['OrderState'=>['in',ProductOrderEnum::$PayComplete],'UpdateTime' => ['<', $new_month]])
->where(['UpdateTime' => ['>', $last_month]])
->where(['UserId' => ['in',$user_id]])
->group(['UserId'])
->order('money')
->fetchAll();
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete], 'UpdateTime' => ['<', $new_month]])
->where(['UpdateTime' => ['>', $last_month]])
->where(['UserId' => ['in', $user_id]])
->group(['UserId'])
->order('money')
->fetchAll();
}
/**
* @description: 获取所有支付成功用户近一个月在筛选范围的支付总金额
* @description: 获取所有支付成功用户的支付总金额
* @param {*}
* @return {*}
*/
public function getScreenMonthCost($screen){
public function getAllCost($user_id)
{
return $this->field('UserId,sum(PaymentAmount) as money')
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
->where(['UserId' => ['in', $user_id]])
->group(['UserId'])
->fetchAll();
}
/**
* @description: 获取所有支付成功用户上一个月在筛选范围的支付总金额
* @param {*}
* @return {*}
*/
public function getScreenMonthCost($screen)
{
$last_month = date("Y-m-01", strtotime("-1 month"));
$new_month = date("Y-m-t", strtotime("-1 month"));
return $this->field('UserId,sum(PaymentAmount) as money')
->where(['OrderState'=>['in',ProductOrderEnum::$PayComplete],'UpdateTime' => ['<', $new_month]])
->where(['UpdateTime' => ['>', $last_month]])
->group(['UserId'],'having money>'.$screen['money1'].' and money<'.$screen['money2'])
->fetchAll();
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete], 'UpdateTime' => ['<', $new_month]])
->where(['UpdateTime' => ['>', $last_month]])
->group(['UserId'], 'having money>' . $screen['money1'] . ' and money<' . $screen['money2'])
->fetchAll();
}
/**
* @description: 获取所有支付成功用户上一个月或者本月支付金额
* @param {*} flag = true 上一个月
* @return {*} false 本月
*/
public function getPreMonthCost($user_id, $where)
{
return $this->field('UserId,sum(PaymentAmount) as money')
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
->where($where)
->where(['UserId' => ['in', $user_id]])
->group(['UserId'])
->order('money')
->fetchAll();
}
/**
* @description: 获取用户所有的帐号记录
* @param {*}
* @return {*}
*/
public function getUserAccount($user_id)
{
return $this->field('UserName,ProductName,PackageName,PaymentAmount,Accounts,UpdateTime')
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete], 'UserId' => $user_id])
->order('Id desc')
->fetchAll();
}
/**
* @description: 按照排序条件进行查询
* @param {*}
* @return {*}
*/
public function getSort($where = [],$order = 1, $limit = '50')
{
$order_type = 'money';
if($order == '0'){
$order_type = 'money desc';
}
return $this->field('product_order.UserId,sum(product_order.PaymentAmount) as money')
->join('user ON product_order.UserId=user.Id')
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
->where($where)
->group(['product_order.UserId'])
->order($order_type)
->limit($limit)
->fetchAll();
}
/**
* @description: 按照排序条件进行查询上一个月或者本月支付金额
* @param {*} flag = true 上一个月
* @return {*} flag = false 本月
*/
public function getMonthSort($where = [],$order = 1, $limit = '50', $flag = true)
{
$order_type = 'money';
if($order == '0'){
$order_type = 'money desc';
}
if ($flag) {
$last_month = date("Y-m-01 H:i:s", strtotime("-1 month"));
$new_month = date("Y-m-t H:i:s", strtotime("-1 month"));
} else {
$last_month = date("Y-m-01 H:i:s", time());
$new_month = date("Y-m-d H:i:s", time());
}
return $this->field('product_order.UserId,sum(product_order.PaymentAmount) as money')
->join('user ON product_order.UserId=user.Id')
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
->where($where)
->where("product_order.UpdateTime >'".$last_month."'")
->where("product_order.UpdateTime <'".$new_month."'")
->group(['product_order.UserId'])
->order($order_type)
->limit($limit)
->fetchAll();
}
/**
* @description: 获取所有支付成功用户筛选金额
* @param {*}
* @return {*}
*/
public function getScreenCost($where,$having, $limit = '50')
{
return $this->field('UserId,sum(PaymentAmount) as money')
->join('user ON product_order.UserId=user.Id')
->where(['OrderState' => ['in', ProductOrderEnum::$PayComplete]])
->where($where)
->group(['UserId'],$having)
->fetchAll();
}
}

View File

@@ -4,8 +4,8 @@
* @version:
* @Author: kangkang
* @Date: 2020-10-16 14:44:02
* @LastEditors: kangkang
* @LastEditTime: 2020-11-16 15:22:30
* @LastEditors: Please set LastEditors
* @LastEditTime: 2020-11-20 15:59:59
*/
namespace app\manager\model;
@@ -26,6 +26,16 @@ class User extends Model
return $this->field('ManagerId,ManagerName,count(1) as count_num')->group(['ManagerId'])->fetchAll();
}
/**
* @description: 获取所有客户经理客户
* @param {*}
* @return {*}
*/
public function getAllManagerUser($where = [])
{
return $this->field('Id,CreateTime')->where($where)->fetchAll();
}
/**
* @description: 查询符合筛选条件的所有用户数量
* @param {*}
@@ -36,7 +46,13 @@ class User extends Model
return $this->field('ManagerId,ManagerName,count(1) as count_num')->where($where)->group(['ManagerId'])->fetchAll();
}
public function setManager($where,$data,$limit){
/**
* @description: 为客户经理分配用户
* @param {*}
* @return {*}
*/
public function setManager($where, $data, $limit)
{
return $this->where($where)->limit($limit)->update($data);
}

View File

@@ -0,0 +1,49 @@
<?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-16 14:44:02
* @LastEditors: kangkang
* @LastEditTime: 2020-11-18 19:34:22
*/
namespace app\manager\model;
use fastphp\base\Model;
class UserScore extends Model
{
protected $table = 'user_score';
/**
* @description: 获取用户所有的消费记录
* @param {*}
* @return {*}
*/
public function getUserCost($user_id, $index)
{
$where = [];
$wheres = [];
switch($index){
case 2:
$last_month = date("Y-m-01 H:i:s", strtotime("-1 month"));
$new_month = date("Y-m-t H:i:s", strtotime("-1 month"));
$where['UpdateTime'] = ['<',$new_month];
$wheres['UpdateTime'] = ['>',$last_month];
break;
case 3:
$last_month = date("Y-m-01 H:i:s", time());
$new_month = date("Y-m-d H:i:s", time());
$where['UpdateTime'] = ['<',$new_month];
$wheres['UpdateTime'] = ['>',$last_month];
break;
}
return $this->field('ScoreTypeName,ScoreValue,RestAmount1,RestAmount2,UpdateTime')
->where(['UserId' => $user_id])
->where($where)
->where($wheres)
->order('Id desc')
->fetchAll();
}
}