Update: update MarketingFrameworkAgreementLists setSearch and related functions
This commit is contained in:
parent
19b70f45dc
commit
6c7bb60abe
@ -3,12 +3,22 @@
|
|||||||
namespace app\adminapi\controller\marketing;
|
namespace app\adminapi\controller\marketing;
|
||||||
|
|
||||||
use app\adminapi\controller\BaseAdminController;
|
use app\adminapi\controller\BaseAdminController;
|
||||||
use app\common\model\dict\DictData;
|
use app\adminapi\logic\marketing\MarketingStatisticsLogic;
|
||||||
|
use app\common\model\dict\DictData;
|
||||||
use app\common\model\marketing\MarketingContract;
|
use app\common\model\marketing\MarketingContract;
|
||||||
use app\common\model\marketing\MarketingCustom;
|
use app\common\model\marketing\MarketingCustom;
|
||||||
|
|
||||||
class MarketingStatisticsController extends BaseAdminController
|
class MarketingStatisticsController extends BaseAdminController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public function index(){
|
||||||
|
$date=$this->request->get('date','');
|
||||||
|
$where=[];
|
||||||
|
$time = getDay($date);
|
||||||
|
$res=MarketingStatisticsLogic::marketingStatistics($where,$time);
|
||||||
|
return $this->data($res);
|
||||||
|
}
|
||||||
|
|
||||||
public function custom(){
|
public function custom(){
|
||||||
$year = $this->request->get('year',date('Y'));
|
$year = $this->request->get('year',date('Y'));
|
||||||
//总客户数
|
//总客户数
|
||||||
|
77
app/adminapi/logic/marketing/MarketingStatisticsLogic.php
Normal file
77
app/adminapi/logic/marketing/MarketingStatisticsLogic.php
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\adminapi\logic\marketing;
|
||||||
|
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\dict\DictData;
|
||||||
|
use app\common\model\marketing\MarketingContract;
|
||||||
|
use app\common\model\marketing\MarketingCustom;
|
||||||
|
|
||||||
|
class MarketingStatisticsLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计
|
||||||
|
*/
|
||||||
|
public static function marketingStatistics($where, $time)
|
||||||
|
{
|
||||||
|
$data = [];
|
||||||
|
$datearr = explode('-', $time);
|
||||||
|
$time = TimeConvert(['start_time' => $datearr[0], 'end_time' => $datearr[1]]);
|
||||||
|
$marketingContract=new MarketingContract();
|
||||||
|
// //统计主合同
|
||||||
|
$total_contract_type_0=$marketingContract->ContractTypeStatistics(['contract_type'=>0],$time,'sum');
|
||||||
|
$total_contract_type_0_value=$marketingContract->ContractTypeStatistics(['contract_type'=>0],$time,'group','create_time');
|
||||||
|
$data[]=[
|
||||||
|
'title' => '主合同',
|
||||||
|
'desc' => '',
|
||||||
|
'total_money' => $total_contract_type_0,
|
||||||
|
'value' => $total_contract_type_0_value['y'],
|
||||||
|
'type' => 1,
|
||||||
|
];
|
||||||
|
// //统计框架协议
|
||||||
|
$total_contract_type_1=$marketingContract->ContractTypeStatistics(['contract_type'=>1],$time,'sum');
|
||||||
|
$total_contract_type_1_value=$marketingContract->ContractTypeStatistics(['contract_type'=>1],$time,'group','create_time');
|
||||||
|
$data[]=[
|
||||||
|
'title' => '框架协议',
|
||||||
|
'desc' => '',
|
||||||
|
'total_money' => $total_contract_type_1,
|
||||||
|
'value' => $total_contract_type_1_value['y'],
|
||||||
|
'type' => 1,
|
||||||
|
];
|
||||||
|
// //统计补充协议
|
||||||
|
$total_contract_type_2=$marketingContract->ContractTypeStatistics(['contract_type'=>2],$time,'sum');
|
||||||
|
$total_contract_type_2_value=$marketingContract->ContractTypeStatistics(['contract_type'=>2],$time,'group','create_time');
|
||||||
|
$data[]=[
|
||||||
|
'title' => '补充协议',
|
||||||
|
'desc' => '',
|
||||||
|
'total_money' => $total_contract_type_2,
|
||||||
|
'value' => $total_contract_type_2_value['y'],
|
||||||
|
'type' => 1,
|
||||||
|
];
|
||||||
|
//统计客户
|
||||||
|
$total_custom=MarketingCustom::count();
|
||||||
|
$data[]=[
|
||||||
|
'title' => '客户总数',
|
||||||
|
'desc' => '',
|
||||||
|
'total_money' => $total_custom,
|
||||||
|
'value' => [],
|
||||||
|
'type' => 1,
|
||||||
|
];
|
||||||
|
//业务性质
|
||||||
|
$business_nature = DictData::where('type_value', 'cost_consultation_business_nature')->column('name', 'value');
|
||||||
|
foreach($business_nature as $key=>$value){
|
||||||
|
$count=$marketingContract->ContractTypeStatistics(['business_nature'=>$key],$time,'sum');
|
||||||
|
$y_value=$marketingContract->ContractTypeStatistics(['business_nature'=>$key],$time,'group','create_time');
|
||||||
|
$data[] = [
|
||||||
|
'title' => $value,
|
||||||
|
'desc' => '',
|
||||||
|
'total_money' => $count,
|
||||||
|
'value' => $y_value['y'],
|
||||||
|
'type' => 1,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
139
app/common.php
139
app/common.php
@ -2,8 +2,8 @@
|
|||||||
// 应用公共文件
|
// 应用公共文件
|
||||||
|
|
||||||
use app\common\model\auth\Admin;
|
use app\common\model\auth\Admin;
|
||||||
use app\common\model\dept\Dept;
|
use app\common\model\dept\Dept;
|
||||||
use app\common\model\oa\Flow;
|
use app\common\model\oa\Flow;
|
||||||
use app\common\model\oa\FlowApprove;
|
use app\common\model\oa\FlowApprove;
|
||||||
use app\common\model\oa\FlowRecord;
|
use app\common\model\oa\FlowRecord;
|
||||||
use app\common\model\oa\FlowStep;
|
use app\common\model\oa\FlowStep;
|
||||||
@ -19,7 +19,7 @@ use think\helper\Str;
|
|||||||
* @author 段誉
|
* @author 段誉
|
||||||
* @date 2021/12/28 18:24
|
* @date 2021/12/28 18:24
|
||||||
*/
|
*/
|
||||||
function create_password(string $plaintext, string $salt) : string
|
function create_password(string $plaintext, string $salt): string
|
||||||
{
|
{
|
||||||
return md5($salt . md5($plaintext . $salt));
|
return md5($salt . md5($plaintext . $salt));
|
||||||
}
|
}
|
||||||
@ -32,10 +32,10 @@ function create_password(string $plaintext, string $salt) : string
|
|||||||
* @author 段誉
|
* @author 段誉
|
||||||
* @date 2021/12/28 18:24
|
* @date 2021/12/28 18:24
|
||||||
*/
|
*/
|
||||||
function create_token(string $extra = '') : string
|
function create_token(string $extra = ''): string
|
||||||
{
|
{
|
||||||
$salt = env('project.unique_identification', 'likeadmin');
|
$salt = env('project.unique_identification', 'likeadmin');
|
||||||
$encryptSalt = md5( $salt . uniqid());
|
$encryptSalt = md5($salt . uniqid());
|
||||||
return md5($salt . $extra . time() . $encryptSalt);
|
return md5($salt . $extra . time() . $encryptSalt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ function create_token(string $extra = '') : string
|
|||||||
* @author 段誉
|
* @author 段誉
|
||||||
* @date 2021/12/28 18:24
|
* @date 2021/12/28 18:24
|
||||||
*/
|
*/
|
||||||
function substr_symbol_behind($str, $symbol = '.') : string
|
function substr_symbol_behind($str, $symbol = '.'): string
|
||||||
{
|
{
|
||||||
$result = strripos($str, $symbol);
|
$result = strripos($str, $symbol);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
@ -65,7 +65,7 @@ function substr_symbol_behind($str, $symbol = '.') : string
|
|||||||
* @author 段誉
|
* @author 段誉
|
||||||
* @date 2021/12/28 18:27
|
* @date 2021/12/28 18:27
|
||||||
*/
|
*/
|
||||||
function compare_php(string $version) : bool
|
function compare_php(string $version): bool
|
||||||
{
|
{
|
||||||
return version_compare(PHP_VERSION, $version) >= 0 ? true : false;
|
return version_compare(PHP_VERSION, $version) >= 0 ? true : false;
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ function compare_php(string $version) : bool
|
|||||||
* @author 段誉
|
* @author 段誉
|
||||||
* @date 2021/12/28 18:27
|
* @date 2021/12/28 18:27
|
||||||
*/
|
*/
|
||||||
function check_dir_write(string $dir = '') : bool
|
function check_dir_write(string $dir = ''): bool
|
||||||
{
|
{
|
||||||
$route = root_path() . '/' . $dir;
|
$route = root_path() . '/' . $dir;
|
||||||
return is_writable($route);
|
return is_writable($route);
|
||||||
@ -271,7 +271,7 @@ function get_no_prefix_table_name($tableName)
|
|||||||
* @author 段誉
|
* @author 段誉
|
||||||
* @date 2023/2/23 11:35
|
* @date 2023/2/23 11:35
|
||||||
*/
|
*/
|
||||||
function generate_sn($table, $field, $prefix = '', $randSuffixLength = 4, $pool = []) : string
|
function generate_sn($table, $field, $prefix = '', $randSuffixLength = 4, $pool = []): string
|
||||||
{
|
{
|
||||||
$suffix = '';
|
$suffix = '';
|
||||||
for ($i = 0; $i < $randSuffixLength; $i++) {
|
for ($i = 0; $i < $randSuffixLength; $i++) {
|
||||||
@ -337,22 +337,22 @@ function getAncestors($categoryId, $categoryTable): array
|
|||||||
if ($item['id'] == $categoryId && $item['pid'] != 0) {
|
if ($item['id'] == $categoryId && $item['pid'] != 0) {
|
||||||
$parentIds[] = $item['pid'];
|
$parentIds[] = $item['pid'];
|
||||||
// 递归调用自身,将父类ID作为参数传入
|
// 递归调用自身,将父类ID作为参数传入
|
||||||
$newParentIds = getAncestors($item['pid'],$categoryTable);
|
$newParentIds = getAncestors($item['pid'], $categoryTable);
|
||||||
$parentIds = array_merge($parentIds, $newParentIds);
|
$parentIds = array_merge($parentIds, $newParentIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $parentIds ;
|
return $parentIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
//数据唯一编码
|
//数据唯一编码
|
||||||
function data_unique_code($str): string
|
function data_unique_code($str): string
|
||||||
{
|
{
|
||||||
//质量检查单-20231215-0001
|
//质量检查单-20231215-0001
|
||||||
return $str.'-'.date('Ymd',time()).'-'.mt_rand(100000, 999999);
|
return $str . '-' . date('Ymd', time()) . '-' . mt_rand(100000, 999999);
|
||||||
}
|
}
|
||||||
|
|
||||||
function daysBetweenDates($start_date,$end_date): bool|int
|
function daysBetweenDates($start_date, $end_date): bool|int
|
||||||
{
|
{
|
||||||
$start = new DateTime($start_date);
|
$start = new DateTime($start_date);
|
||||||
$end = new DateTime($end_date);
|
$end = new DateTime($end_date);
|
||||||
@ -360,11 +360,11 @@ function daysBetweenDates($start_date,$end_date): bool|int
|
|||||||
return $interval->days;
|
return $interval->days;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addApprove($title,$content_id,$content_model,$path,$flow_id,$create_user_id)
|
function addApprove($title, $content_id, $content_model, $path, $flow_id, $create_user_id)
|
||||||
{
|
{
|
||||||
$createUser = Admin::field('name,dept_id')->where('id',$create_user_id)->findOrEmpty();
|
$createUser = Admin::field('name,dept_id')->where('id', $create_user_id)->findOrEmpty();
|
||||||
//获取审批流程信息
|
//获取审批流程信息
|
||||||
$flowData = Flow::where('id',$flow_id)->findOrEmpty();
|
$flowData = Flow::where('id', $flow_id)->findOrEmpty();
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
//添加审批内容
|
//添加审批内容
|
||||||
@ -378,14 +378,14 @@ function addApprove($title,$content_id,$content_model,$path,$flow_id,$create_use
|
|||||||
'check_status' => 0,
|
'check_status' => 0,
|
||||||
]);
|
]);
|
||||||
$flowStepData = [];
|
$flowStepData = [];
|
||||||
foreach($flowData['flow_list'] as $k=>$v){
|
foreach ($flowData['flow_list'] as $k => $v) {
|
||||||
$flowStepData[] = [
|
$flowStepData[] = [
|
||||||
'approve_id' => $approveRes->id,
|
'approve_id' => $approveRes->id,
|
||||||
'flow_name' => $flowData['check_type'] == 1 ? '' : $v['flow_step'],
|
'flow_name' => $flowData['check_type'] == 1 ? '' : $v['flow_step'],
|
||||||
'flow_step' => $flowData['check_type'] == 1 ? $v['flow_step'] : 0,
|
'flow_step' => $flowData['check_type'] == 1 ? $v['flow_step'] : 0,
|
||||||
'flow_user' => implode(',',$v['flow_user']),
|
'flow_user' => implode(',', $v['flow_user']),
|
||||||
'sort' => $k+1,
|
'sort' => $k + 1,
|
||||||
'is_active' => $k==0 ? 1 : 0,
|
'is_active' => $k == 0 ? 1 : 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
array_unshift($flowStepData, [
|
array_unshift($flowStepData, [
|
||||||
@ -397,7 +397,7 @@ function addApprove($title,$content_id,$content_model,$path,$flow_id,$create_use
|
|||||||
'is_active' => 0,
|
'is_active' => 0,
|
||||||
]);
|
]);
|
||||||
//添加审批步骤
|
//添加审批步骤
|
||||||
foreach($flowStepData as $v){
|
foreach ($flowStepData as $v) {
|
||||||
FlowStep::create($v);
|
FlowStep::create($v);
|
||||||
}
|
}
|
||||||
//添加审批记录
|
//添加审批记录
|
||||||
@ -407,7 +407,7 @@ function addApprove($title,$content_id,$content_model,$path,$flow_id,$create_use
|
|||||||
'check_user_id' => 0,
|
'check_user_id' => 0,
|
||||||
'check_time' => time(),
|
'check_time' => time(),
|
||||||
'status' => 0,
|
'status' => 0,
|
||||||
'title' => $createUser['name'].'提交了此申请',
|
'title' => $createUser['name'] . '提交了此申请',
|
||||||
'content' => '提交申请',
|
'content' => '提交申请',
|
||||||
'is_invalid' => 0
|
'is_invalid' => 0
|
||||||
]);
|
]);
|
||||||
@ -418,3 +418,98 @@ function addApprove($title,$content_id,$content_model,$path,$flow_id,$create_use
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索时间转换
|
||||||
|
* @param $timeKey
|
||||||
|
* @param false $isNum
|
||||||
|
* @return array
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
function TimeConvert($timeKey, $isNum = false)
|
||||||
|
{
|
||||||
|
switch ($timeKey) {
|
||||||
|
case "today":
|
||||||
|
$data['start_time'] = date('Y-m-d 00:00:00', time());
|
||||||
|
$data['end_time'] = date('Y-m-d 23:59:59', time());
|
||||||
|
$data['days'] = 1;
|
||||||
|
break;
|
||||||
|
case "yestoday":
|
||||||
|
$data['start_time'] = date('Y-m-d 00:00:00', strtotime('-1 day'));
|
||||||
|
$data['end_time'] = date('Y-m-d 23:59:59', strtotime('-1 day'));
|
||||||
|
$data['days'] = 1;
|
||||||
|
break;
|
||||||
|
case "last_month":
|
||||||
|
$data['start_time'] = date('Y-m-01 00:00:00', strtotime('-1 month'));
|
||||||
|
$data['end_time'] = date('Y-m-t 23:59:59', strtotime('-1 month'));
|
||||||
|
$data['days'] = 30;
|
||||||
|
break;
|
||||||
|
case "month":
|
||||||
|
$data['start_time'] = $month_start_time = date('Y-m-01 00:00:00', strtotime(date("Y-m-d")));
|
||||||
|
$data['end_time'] = date('Y-m-d 23:59:59', strtotime("$month_start_time +1 month -1 day"));
|
||||||
|
$data['days'] = 30;
|
||||||
|
break;
|
||||||
|
case "year":
|
||||||
|
$data['start_time'] = date('Y-01-01 00:00:00', time());
|
||||||
|
$data['end_time'] = date('Y-12-t 23:59:59', time());
|
||||||
|
$data['days'] = 365;
|
||||||
|
break;
|
||||||
|
case "last_year":
|
||||||
|
$data['start_time'] = date('Y-01-01 00:00:00', strtotime('-1 year'));
|
||||||
|
$data['end_time'] = date('Y-12-t 23:59:59', strtotime('-1 year'));
|
||||||
|
$data['days'] = 365;
|
||||||
|
break;
|
||||||
|
case 30:
|
||||||
|
case 15:
|
||||||
|
case 7:
|
||||||
|
if (!$isNum) {
|
||||||
|
$data['start_time'] = date("Y-m-d 00:00:00", strtotime("-$timeKey day"));
|
||||||
|
$data['end_time'] = date('Y-m-d 23:59:59', time());
|
||||||
|
$data['days'] = $timeKey;
|
||||||
|
} else {
|
||||||
|
$day = $timeKey * 2;
|
||||||
|
$data['start_time'] = date("Y-m-d 00:00:00", strtotime("-$day day"));
|
||||||
|
$data['end_time'] = date("Y-m-d 23:59:59", strtotime("-$timeKey day"));
|
||||||
|
$data['days'] = $timeKey;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$datetime_start = new \DateTime($timeKey['start_time']);
|
||||||
|
$datetime_end = new \DateTime($timeKey['end_time']);
|
||||||
|
$days = $datetime_start->diff($datetime_end)->days;
|
||||||
|
$days = $days > 0 ? $days : 1;
|
||||||
|
if (!$isNum) {
|
||||||
|
$data['start_time'] = $timeKey['start_time'];
|
||||||
|
$data['end_time'] = $timeKey['end_time'];
|
||||||
|
$data['days'] = $days;
|
||||||
|
} else {
|
||||||
|
$data['start_time'] = date("Y-m-d 00:00:00", strtotime("-$days day"));
|
||||||
|
$data['end_time'] = $timeKey['start_time'];
|
||||||
|
$data['days'] = $days;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化时间
|
||||||
|
* @param $time
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getDay($time)
|
||||||
|
{
|
||||||
|
if (strstr($time, '-') !== false) {
|
||||||
|
[$startTime, $endTime] = explode('-', $time);
|
||||||
|
if (!$startTime && !$endTime) {
|
||||||
|
return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d", time());
|
||||||
|
} else {
|
||||||
|
if ($startTime == $endTime) {
|
||||||
|
return $startTime . '-' . $endTime . ' 23:59:59';
|
||||||
|
} else {
|
||||||
|
return $startTime . '-' . $endTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d", time());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -12,19 +12,19 @@
|
|||||||
// | author: likeadminTeam
|
// | author: likeadminTeam
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace app\common\model;
|
namespace app\common\model;
|
||||||
|
|
||||||
use app\common\model\dict\DictData;
|
use app\common\model\dict\DictData;
|
||||||
use app\common\service\FileService;
|
use app\common\service\FileService;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 基础模型
|
* 基础模型
|
||||||
* Class BaseModel
|
* Class BaseModel
|
||||||
* @package app\common\model
|
* @package app\common\model
|
||||||
*/
|
*/
|
||||||
class BaseModel extends Model
|
class BaseModel extends Model
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @notes 公共处理图片,补全路径
|
* @notes 公共处理图片,补全路径
|
||||||
* @param $value
|
* @param $value
|
||||||
@ -60,4 +60,102 @@
|
|||||||
return !empty($data['approve_check_status']) ? $dict[$data['approve_check_status']] : '待审核';
|
return !empty($data['approve_check_status']) ? $dict[$data['approve_check_status']] : '待审核';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 曲线统计
|
||||||
|
* @param $time
|
||||||
|
* @param $type
|
||||||
|
* @param $timeType
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getCurveData($where, $time, $str, string $group = 'create_time')
|
||||||
|
{
|
||||||
|
return $this->where($where)
|
||||||
|
->when(isset($time), function ($query) use ($time, $str, $group) {
|
||||||
|
$query->whereBetweenTime($group, $time['start_time'], $time['end_time']);
|
||||||
|
if ($time['days'] == 1) {
|
||||||
|
$timeUinx = "%H";
|
||||||
|
} elseif ($time['days'] == 30) {
|
||||||
|
$timeUinx = "%Y-%m-%d";
|
||||||
|
} elseif ($time['days'] == 365) {
|
||||||
|
$timeUinx = "%Y-%m";
|
||||||
|
} elseif ($time['days'] > 1 && $time['days'] < 30) {
|
||||||
|
$timeUinx = "%Y-%m-%d";
|
||||||
|
} elseif ($time['days'] > 30 && $time['days'] < 365) {
|
||||||
|
$timeUinx = "%Y-%m";
|
||||||
|
} else {
|
||||||
|
$timeUinx = "%Y-%m";
|
||||||
}
|
}
|
||||||
|
$query->field("$str as number,FROM_UNIXTIME($group, '$timeUinx') as time");
|
||||||
|
$query->group("FROM_UNIXTIME($group, '$timeUinx')");
|
||||||
|
})
|
||||||
|
->order("$group ASC")->select()->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理Y坐标数据
|
||||||
|
* @param array $data
|
||||||
|
* @param array $timeKey
|
||||||
|
* @return array
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function trendYdata(array $data, array $timeKey)
|
||||||
|
{
|
||||||
|
$hourMoney = array();
|
||||||
|
$timeData = array();
|
||||||
|
//获取日期之间的天数
|
||||||
|
$getDayRange = function ($date, $timeKey) {
|
||||||
|
$datearr = [];
|
||||||
|
$stime = strtotime($timeKey['start_time']);
|
||||||
|
$etime = strtotime($timeKey['end_time']);
|
||||||
|
while ($stime <= $etime) {
|
||||||
|
$datearr['x'][] = date($date, $stime);
|
||||||
|
$datearr['y'][] = date($date, $stime);
|
||||||
|
$stime = $stime + 86400;
|
||||||
|
}
|
||||||
|
return $datearr;
|
||||||
|
};
|
||||||
|
//获取日期之间的月份
|
||||||
|
$getMonthRange = function ($date, $timeKey) {
|
||||||
|
$datearr = [];
|
||||||
|
$stime = date('Y-m-d', strtotime($timeKey['start_time']));
|
||||||
|
$etime = date('Y-m-d', strtotime($timeKey['end_time']));
|
||||||
|
$start = new \DateTime($stime);
|
||||||
|
$end = new \DateTime($etime);
|
||||||
|
$interval = \DateInterval::createFromDateString('1 month');
|
||||||
|
$period = new \DatePeriod($start, $interval, $end);
|
||||||
|
foreach ($period as $dt) {
|
||||||
|
$datearr['x'][] = $dt->format($date);
|
||||||
|
$datearr['y'][] = $dt->format($date);
|
||||||
|
}
|
||||||
|
return $datearr;
|
||||||
|
};
|
||||||
|
if ($timeKey['days'] == 1) {
|
||||||
|
for ($i = 0; $i <= 24; $i++) {
|
||||||
|
$timeData['x'][] = (string)($i < 10 ? ('0' . $i) : $i);
|
||||||
|
$timeData['y'][] = $i < 10 ? ('0' . $i) : $i;
|
||||||
|
//$timeData['y'][] = $i < 10 ? ('0' . $i . ":00") : $i . ":00";
|
||||||
|
//$timeData['x'][] = $i < 10 ? ('0' . $i . ":00") : $i . ":00";
|
||||||
|
}
|
||||||
|
} elseif ($timeKey['days'] == 30) {
|
||||||
|
$timeData = $getDayRange('Y-m-d', $timeKey);
|
||||||
|
} elseif ($timeKey['days'] == 365) {
|
||||||
|
$timeData = $getMonthRange('Y-m', $timeKey);
|
||||||
|
} elseif ($timeKey['days'] > 1 && $timeKey['days'] < 30) {
|
||||||
|
$timeData = $getDayRange('Y-m-d', $timeKey);
|
||||||
|
} elseif ($timeKey['days'] > 30 && $timeKey['days'] < 365) {
|
||||||
|
$timeData = $getMonthRange('Y-m', $timeKey);
|
||||||
|
}
|
||||||
|
if ($data) {
|
||||||
|
$hourMoney = array_column($data, 'number', 'time');
|
||||||
|
}
|
||||||
|
$y = array();
|
||||||
|
foreach ($timeData['y'] as $k => $v) {
|
||||||
|
if (array_key_exists($v, $hourMoney)) {
|
||||||
|
$y[$v] = $hourMoney[$v];
|
||||||
|
} else {
|
||||||
|
$y[$v] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ['x' => $timeData['x'], 'y' => $y];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -12,21 +12,21 @@
|
|||||||
// | author: likeadminTeam
|
// | author: likeadminTeam
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace app\common\model\marketing;
|
namespace app\common\model\marketing;
|
||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
use app\common\model\dict\DictData;
|
use app\common\model\dict\DictData;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 市场经营--合同信息模型
|
* 市场经营--合同信息模型
|
||||||
* Class MarketingContract
|
* Class MarketingContract
|
||||||
* @package app\common\model\marketing
|
* @package app\common\model\marketing
|
||||||
*/
|
*/
|
||||||
class MarketingContract extends BaseModel
|
class MarketingContract extends BaseModel
|
||||||
{
|
{
|
||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
|
|
||||||
protected $name = 'marketing_contract';
|
protected $name = 'marketing_contract';
|
||||||
@ -106,13 +106,12 @@
|
|||||||
|
|
||||||
public function getReviewStatusTextAttr($value, $data): string
|
public function getReviewStatusTextAttr($value, $data): string
|
||||||
{
|
{
|
||||||
if($data['contract_type'] == 0){
|
if ($data['contract_type'] == 0) {
|
||||||
$arr = [0 => '待移交', 1 => '已移交'];
|
$arr = [0 => '待移交', 1 => '已移交'];
|
||||||
return $arr[$data['review_status']];
|
return $arr[$data['review_status']];
|
||||||
}else{
|
} else {
|
||||||
return '不可移交';
|
return '不可移交';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStatusTextAttr($value, $data): string
|
public function getStatusTextAttr($value, $data): string
|
||||||
@ -147,4 +146,28 @@
|
|||||||
{
|
{
|
||||||
return !empty($value) ? date('Y-m-d', $value) : '';
|
return !empty($value) ? date('Y-m-d', $value) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计合同类型
|
||||||
|
*/
|
||||||
|
public function ContractTypeStatistics($where, $time, string $selectType, string $group = "")
|
||||||
|
{
|
||||||
|
switch ($selectType) {
|
||||||
|
case "sum":
|
||||||
|
$totalMoney = $this->where($where)->when(isset($time), function ($query) use ($time) {
|
||||||
|
$query->whereBetweenTime('create_time', strtotime($time['start_time']), strtotime($time['end_time']));
|
||||||
|
})->count();
|
||||||
|
break;
|
||||||
|
case "group":
|
||||||
|
$totalMoney = $this->getCurveData($where, $time, 'count(id)', $group);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \Exception('getOrderTotalMoney:selectType参数错误');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($group) {
|
||||||
|
$totalMoney = $this->trendYdata((array)$totalMoney, $time);
|
||||||
|
}
|
||||||
|
return $totalMoney;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -12,21 +12,21 @@
|
|||||||
// | author: likeadminTeam
|
// | author: likeadminTeam
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace app\common\model\marketing;
|
namespace app\common\model\marketing;
|
||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
use app\common\model\dict\DictData;
|
use app\common\model\dict\DictData;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 市场经营--客户信息模型
|
* 市场经营--客户信息模型
|
||||||
* Class MarketingCustom
|
* Class MarketingCustom
|
||||||
* @package app\common\model\marketing
|
* @package app\common\model\marketing
|
||||||
*/
|
*/
|
||||||
class MarketingCustom extends BaseModel
|
class MarketingCustom extends BaseModel
|
||||||
{
|
{
|
||||||
use SoftDelete;
|
use SoftDelete;
|
||||||
|
|
||||||
protected $name = 'marketing_custom';
|
protected $name = 'marketing_custom';
|
||||||
@ -43,4 +43,4 @@
|
|||||||
$dict = DictData::where('type_value', 'custom_category')->column('name', 'value');
|
$dict = DictData::where('type_value', 'custom_category')->column('name', 'value');
|
||||||
return !empty($data['category']) ? $dict[$data['category']] : '';
|
return !empty($data['category']) ? $dict[$data['category']] : '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user