维护用户自动分配用户

This commit is contained in:
wanyongkang
2020-11-17 14:30:54 +08:00
parent 6f855854f3
commit 5295c13f73
4 changed files with 360 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
<?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-16 14:44:02
* @LastEditors: kangkang
* @LastEditTime: 2020-11-14 10:00:42
*/
namespace app\manager\model;
use fastphp\base\Model;
class Manager extends Model
{
protected $table = 'manager';
public function getAllList($where = []){
return $this->field('id,RealName')->where($where)->where(['IsRoot'=>0,'RoleId'=>100])->fetchAll();
}
}

View 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();
}
}

View File

@@ -0,0 +1,43 @@
<?php
/*
* @Descripttion:
* @version:
* @Author: kangkang
* @Date: 2020-10-16 14:44:02
* @LastEditors: kangkang
* @LastEditTime: 2020-11-16 15:22:30
*/
namespace app\manager\model;
use fastphp\base\Model;
class User extends Model
{
protected $table = 'user';
/**
* @description: 获取所有客户经理客户数量
* @param {*}
* @return {*}
*/
public function getAllManagerUserCount()
{
return $this->field('ManagerId,ManagerName,count(1) as count_num')->group(['ManagerId'])->fetchAll();
}
/**
* @description: 查询符合筛选条件的所有用户数量
* @param {*}
* @return {*}
*/
public function getScreenUserCount($where)
{
return $this->field('ManagerId,ManagerName,count(1) as count_num')->where($where)->group(['ManagerId'])->fetchAll();
}
public function setManager($where,$data,$limit){
return $this->where($where)->limit($limit)->update($data);
}
}