消费统计界面基础表格和搜索
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user