维护用户自动分配用户
This commit is contained in:
64
app/manager/model/ProductOrder.php
Normal file
64
app/manager/model/ProductOrder.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/*
|
||||
* @Descripttion:
|
||||
* @version:
|
||||
* @Author: kangkang
|
||||
* @Date: 2020-10-16 14:44:02
|
||||
* @LastEditors: kangkang
|
||||
* @LastEditTime: 2020-11-16 16:22:02
|
||||
*/
|
||||
|
||||
namespace app\manager\model;
|
||||
|
||||
use fastphp\base\Model;
|
||||
use enum\order\ProductOrder as ProductOrderEnum;
|
||||
|
||||
class ProductOrder extends Model
|
||||
{
|
||||
protected $table = 'product_order';
|
||||
|
||||
/**
|
||||
* @description: 获取所有支付成功用户的支付总金额
|
||||
* @param {*}
|
||||
* @return {*}
|
||||
*/
|
||||
public function getCost(){
|
||||
return $this->field('UserId,sum(PaymentAmount) as money')
|
||||
->where(['OrderState'=>['in',ProductOrderEnum::$PayComplete]])
|
||||
->group(['UserId'])
|
||||
->order('money')
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取所有支付成功用户近一个月的支付总金额
|
||||
* @param {*}
|
||||
* @return {*}
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user