Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
T
taote
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
李达
taote
Commits
170e5183
提交
170e5183
authored
7月 14, 2021
作者:
Junlz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
计算预估值
上级
8e838b48
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
355 行增加
和
0 行删除
+355
-0
Tools.php
application/common/library/Tools.php
+11
-0
DayNums.php
application/common/model/DayNums.php
+32
-0
Ex.php
application/common/model/Ex.php
+9
-0
IncomeModel.php
application/common/model/IncomeModel.php
+37
-0
NewUser.php
application/common/model/NewUser.php
+24
-0
User.php
application/common/model/User.php
+11
-0
Income.php
application/index/controller/Income.php
+231
-0
没有找到文件。
application/common/library/Tools.php
0 → 100644
浏览文件 @
170e5183
<?php
namespace
app\common\library
;
class
Tools
{
//获取
}
\ No newline at end of file
application/common/model/DayNums.php
0 → 100644
浏览文件 @
170e5183
<?php
namespace
app\common\model
;
use
think\Model
;
class
DayNums
extends
Model
{
// 表名
protected
$name
=
'day_nums'
;
// 自动写入时间戳字段
protected
$autoWriteTimestamp
=
'int'
;
// 定义时间戳字段名
protected
$createTime
=
'create_time'
;
//添加数据
public
static
function
add
(
$data
)
{
return
self
::
insertGetId
(
$data
);
}
//统计数量
public
static
function
count_nums
(
$start_month
,
$end_month
,
$cid
)
{
$res
=
self
::
where
([
"chief_id"
=>
$cid
])
->
whereBetween
(
'create_time'
,[
$start_month
,
$end_month
])
->
select
();
return
$res
;
}
}
\ No newline at end of file
application/common/model/Ex.php
浏览文件 @
170e5183
...
@@ -43,4 +43,13 @@ class Ex extends Model
...
@@ -43,4 +43,13 @@ class Ex extends Model
return
$data
;
return
$data
;
}
}
/***
* 统计站长每天的订单金额和订单量
* zhanglijun
*/
public
static
function
get_day_income
(
$start_time
,
$end_time
,
$popularize_id
)
{
return
self
::
where
(
'name8'
,
$popularize_id
)
->
whereBetween
(
'name2'
,[
$start_time
,
$end_time
])
->
field
(
'name2,name8,name13'
)
->
select
();
}
}
}
application/common/model/IncomeModel.php
0 → 100644
浏览文件 @
170e5183
<?php
namespace
app\common\model
;
use
think\Model
;
use
app\common\model\User
;
class
IncomeModel
extends
Model
{
// 表名
protected
$name
=
'month_income'
;
// 自动写入时间戳字段
protected
$autoWriteTimestamp
=
'int'
;
// 定义时间戳字段名
protected
$createTime
=
'create_time'
;
/***
* @param $popularize_id
* @param $month
* @return IncomeModel|null
* @throws \think\exception\DbException
* 获取收入
*/
public
static
function
getIncome
(
$popularize_id
,
$month
)
{
return
self
::
where
([
"chief_id"
=>
$popularize_id
,
"month"
=>
$month
]);
}
public
static
function
add
(
$data
)
{
return
self
::
insertGetId
(
$data
);
}
}
\ No newline at end of file
application/common/model/NewUser.php
0 → 100644
浏览文件 @
170e5183
<?php
namespace
app\common\model
;
use
think\Model
;
class
NewUser
extends
Model
{
// 表名
protected
$name
=
'new_user'
;
// 自动写入时间戳字段
protected
$autoWriteTimestamp
=
'int'
;
// 定义时间戳字段名
protected
$createTime
=
'create_time'
;
public
static
function
get_new_count
(
$popularize_id
,
$start_time
,
$end_time
)
{
$res
=
self
::
where
([
"popularize_id"
=>
$popularize_id
])
->
whereBetween
(
'create_time'
,[
$start_time
,
$end_time
])
->
select
();
return
count
(
$res
);
}
}
\ No newline at end of file
application/common/model/User.php
浏览文件 @
170e5183
...
@@ -135,4 +135,15 @@ class User extends Model
...
@@ -135,4 +135,15 @@ class User extends Model
}
}
return
$level
;
return
$level
;
}
}
/****
* 获取用户的信息
* zhanglijun
* 2021.07.14
*/
public
static
function
get_user_info
(
$uid
)
{
return
self
::
get
(
$uid
);
}
}
}
application/index/controller/Income.php
0 → 100644
浏览文件 @
170e5183
<?php
namespace
app\index\controller
;
use
app\admin\command\Api
;
use
app\common\model\DayNums
;
use
app\common\model\Ex
;
use
app\common\model\IncomeModel
;
use
app\common\model\NewUser
;
use
app\common\model\User
;
use
think\Db
;
use
think\Request
;
class
Income
extends
Api
{
private
$uid
;
private
$user_info
;
public
function
__construct
(
$name
=
null
)
{
if
(
empty
(
$_COOKIE
[
"token"
])){
exit
(
"您还未登录"
);
}
date_default_timezone_set
(
'PRC'
);
$this
->
uid
=
$_COOKIE
[
"uid"
];
$this
->
user_info
=
User
::
get_user_info
(
$this
->
uid
);
parent
::
__construct
(
$name
);
}
/***
* 查询每个月的收入接口
* zhanglijun
* 2021-07-14
*/
public
function
get_income
(
Request
$request
)
{
$month
=
$request
->
get
(
"month"
);
if
(
empty
(
$month
)){
$month
=
1
;
}
$popularize_id
=
$this
->
user_info
[
"popularize_id"
];
$data
=
IncomeModel
::
getIncome
(
$popularize_id
,
$month
);
$json_data
=
[
"code"
=>
1
,
"msg"
=>
"success"
,
"data"
=>
$data
];
return
json
(
$json_data
);
}
/***
* 计算预估收入
* zhanglijun
* 2021-07-14
*/
public
function
predict_income
()
{
$order_income
=
0.00
;
$new_reward
=
0.00
;
$base_salary
=
0.00
;
$achievement_reward
=
0.00
;
$month_start
=
strtotime
(
date
(
'Y-m-01'
,
time
()));
$curren_end
=
strtotime
(
date
(
'Y-m-d'
,
time
()));
$diff_time
=
$curren_end
-
$month_start
;
$days
=
bcdiv
(
$diff_time
,
86400
);
//计算平均订单
$popularize_id
=
$this
->
user_info
[
"popularize_id"
];
$res
=
DayNums
::
count_nums
(
$month_start
,
$curren_end
,
$popularize_id
);
if
(
empty
(
$res
)){
return
'无数据'
;
}
$order_nums
=
array_sum
(
array_column
(
$res
,
'order_num'
));
//上个月的平均单量
$ave_order_num
=
bcdiv
(
$order_nums
,
$days
,
2
);
if
(
$order_nums
>=
3000
){
$base_salary
=
1800
;
$achievement_reward
=
1000
;
}
switch
(
$ave_order_num
){
case
$ave_order_num
>=
1
&&
$ave_order_num
<
30
:
$order_income
=
bcmul
(
$order_nums
,
0.60
,
2
);
break
;
case
$ave_order_num
>=
30
&&
$ave_order_num
<
50
:
$order_income
=
bcmul
(
$order_nums
,
0.70
,
2
);
break
;
case
$ave_order_num
>=
50
:
$order_income
=
bcmul
(
$order_nums
,
0.80
,
2
);
break
;
case
$ave_order_num
==
50
:
$order_income
=
0.00
;
break
;
}
$new_user
=
array_sum
(
array_column
(
$res
,
'new_user'
));
//上个月的平均拉新人数
$count
=
bcdiv
(
$new_user
,
$days
,
2
);
switch
(
$count
){
case
$count
>=
1
&&
$count
<
50
:
$new_reward
=
bcmul
(
$count
,
5.00
,
2
);
break
;
case
$count
>=
50
&&
$count
<
100
:
$new_reward
=
bcmul
(
$count
,
6.00
,
2
);
break
;
case
$count
>=
100
:
$new_reward
=
bcmul
(
$count
,
7.00
,
2
);
break
;
case
$count
==
0
:
$new_reward
=
0.00
;
break
;
}
$amount
=
bcadd
(
bcadd
(
$base_salary
,
$order_income
,
2
),
bcadd
(
$achievement_reward
,
$new_reward
,
2
),
2
);
return
$amount
;
}
/****
* 计算上个月的收入
* zhanglijun
* 此脚本一个月跑一次
*/
public
function
last_month_income
()
{
$order_income
=
0.00
;
$new_reward
=
0.00
;
$base_salary
=
0.00
;
$achievement_reward
=
0.00
;
$month_start
=
strtotime
(
date
(
'Y-m-01'
,
strtotime
(
'-1 month'
)));
$month_end
=
strtotime
(
date
(
'Y-m-t'
,
strtotime
(
'-1 month'
)));
//$diff_time = $month_end - $month_start;
$days
=
date
(
"t"
,
strtotime
(
"-1 month"
));
$last_month
=
date
(
"m"
,
strtotime
(
"-1 month"
));
//计算平均订单
$popularize_id
=
$this
->
user_info
[
"popularize_id"
];
$res
=
DayNums
::
count_nums
(
$month_start
,
$month_end
,
$popularize_id
);
if
(
empty
(
$res
)){
return
'无数据'
;
}
$order_nums
=
array_sum
(
array_column
(
$res
,
'order_num'
));
//上个月的平均单量
$ave_order_num
=
bcdiv
(
$order_nums
,
$days
,
2
);
if
(
$order_nums
>=
3000
){
$base_salary
=
1800
;
$achievement_reward
=
1000
;
}
switch
(
$ave_order_num
){
case
$ave_order_num
>=
1
&&
$ave_order_num
<
30
:
$order_income
=
bcmul
(
$order_nums
,
0.60
,
2
);
break
;
case
$ave_order_num
>=
30
&&
$ave_order_num
<
50
:
$order_income
=
bcmul
(
$order_nums
,
0.70
,
2
);
break
;
case
$ave_order_num
>=
50
:
$order_income
=
bcmul
(
$order_nums
,
0.80
,
2
);
break
;
case
$ave_order_num
==
50
:
$order_income
=
0.00
;
break
;
}
$new_user
=
array_sum
(
array_column
(
$res
,
'new_user'
));
//上个月的平均拉新人数
$count
=
bcdiv
(
$new_user
,
$days
,
2
);
switch
(
$count
){
case
$count
>=
1
&&
$count
<
50
:
$new_reward
=
bcmul
(
$count
,
5.00
,
2
);
break
;
case
$count
>=
50
&&
$count
<
100
:
$new_reward
=
bcmul
(
$count
,
6.00
,
2
);
break
;
case
$count
>=
100
:
$new_reward
=
bcmul
(
$count
,
7.00
,
2
);
break
;
case
$count
==
0
:
$new_reward
=
0.00
;
break
;
}
$insert_data
=
[
"phone"
=>
$this
->
user_info
[
"mobile"
]
??
0
,
"chief_id"
=>
$popularize_id
,
"base_salary"
=>
$base_salary
,
"order_subsidy"
=>
$order_income
,
"achievement_reward"
=>
$achievement_reward
,
"month"
=>
$last_month
,
"new_reward"
=>
$new_reward
,
"amount"
=>
bcadd
(
bcadd
(
$base_salary
,
$order_income
,
2
),
bcadd
(
$achievement_reward
,
$new_reward
,
2
),
2
),
"create_time"
=>
time
()
];
return
IncomeModel
::
add
(
$insert_data
);
}
/***
* 订单金额统计
* zhanglijun
* 2021-07-14
*/
public
function
day_all_income
(
Request
$request
)
{
$new_reward
=
0.00
;
//
$order_income
=
0.00
;
$base_salary
=
0.00
;
//底薪
$achievement_reward
=
0.00
;
//业绩达标
$y
=
date
(
"Y"
,
time
());
$m
=
date
(
"m"
,
time
());
$d
=
date
(
"d"
,
time
()
-
60
*
60
*
24
);
$start_time
=
mktime
(
0
,
0
,
0
,
$m
,
$d
,
$y
);
$end_time
=
$start_time
+
60
*
60
*
24
;
$popularize_id
=
$this
->
user_info
[
"popularize_id"
];
$res
=
Ex
::
get_day_income
(
$start_time
,
$end_time
,
$popularize_id
);
//前一天订单数量
$order_nums
=
array_sum
(
array_column
(
$res
,
'name13'
));
//前一天拉新人数
$new_user
=
NewUser
::
get_new_count
(
$popularize_id
,
$start_time
,
$end_time
);
$add_day_income
=
[
"phone"
=>
$this
->
user_info
[
"mobile"
]
??
0
,
"chief_id"
=>
$popularize_id
,
"order_num"
=>
$order_nums
,
"new_user"
=>
$new_user
,
"create_time"
=>
time
()
];
return
DayNums
::
add
(
$add_day_income
);
}
}
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论