Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
goods
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
goods
Commits
ae3ee325
Commit
ae3ee325
authored
Aug 24, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 团长分销,数据统计
parent
f24583d3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
26 deletions
+114
-26
ColonelCenterValidate.php
application/library/Validate/ColonelCenterValidate.php
+14
-0
ColonelDistributorPayInfo.php
...tion/models/marketing/mysql/ColonelDistributorPayInfo.php
+2
-2
Colonel.php
application/modules/Marketing/controllers/Colonel.php
+37
-8
PindanActivityInviteOrderService.php
...n/services/marketing/PindanActivityInviteOrderService.php
+61
-16
No files found.
application/library/Validate/ColonelCenterValidate.php
0 → 100644
View file @
ae3ee325
<?php
namespace
Validate
;
class
ColonelCenterValidate
extends
BaseValidate
{
protected
$rule
=
[
'user_id'
=>
'require'
,
];
protected
$message
=
[
'user_id'
=>
'user_id 参数不能为空'
,
];
}
\ No newline at end of file
application/models/marketing/mysql/ColonelDistributorPayInfo.php
View file @
ae3ee325
...
@@ -6,9 +6,9 @@ use Api\PhpUtils\Mysql\MysqlBase;
...
@@ -6,9 +6,9 @@ use Api\PhpUtils\Mysql\MysqlBase;
class
ColonelDistributorPayInfo
extends
MysqlBase
class
ColonelDistributorPayInfo
extends
MysqlBase
{
{
const
TABLE_NAME
=
'
pindan_activity
_pay_info'
;
const
TABLE_NAME
=
'
colonel_distributor
_pay_info'
;
const
CONFIG_INDEX
=
'marketing'
;
const
CONFIG_INDEX
=
'marketing'
;
const
PRIMARY_KEY
=
'
pindan_activity
_pay_info_id'
;
const
PRIMARY_KEY
=
'
colonel_distributor
_pay_info_id'
;
public
static
function
getRecord
(
$where
,
$columns
=
[],
$options
=
[])
public
static
function
getRecord
(
$where
,
$columns
=
[],
$options
=
[])
{
{
...
...
application/modules/Marketing/controllers/Colonel.php
View file @
ae3ee325
...
@@ -10,9 +10,11 @@ use App\Services\marketing\ColonelService;
...
@@ -10,9 +10,11 @@ use App\Services\marketing\ColonelService;
use
\Validate\ColonelApplyValidate
;
use
\Validate\ColonelApplyValidate
;
use
\Validate\ColonelConfigValidate
;
use
\Validate\ColonelConfigValidate
;
use
\Validate\ColonelAuditValidate
;
use
\Validate\ColonelAuditValidate
;
use
\Validate\ColonelCenterValidate
;
use
\Validate\ColonelAddPoint
;
use
\Validate\ColonelAddPoint
;
use
\App\Services\marketing\PindanActivityColonelConfigService
;
use
\App\Services\marketing\PindanActivityColonelConfigService
;
use
\App\Services\marketing\PindanActivityInviteOrderService
;
use
\App\Services\marketing\PindanActivityInviteOrderService
;
use
\App\Services\user\UserService
;
class
ColonelController
extends
Base
class
ColonelController
extends
Base
{
{
...
@@ -56,7 +58,7 @@ class ColonelController extends Base
...
@@ -56,7 +58,7 @@ class ColonelController extends Base
$params
=
$this
->
params
;
$params
=
$this
->
params
;
$data
=
PindanActivityColonelConfigService
::
colonelConfig
(
$params
);
$data
=
PindanActivityColonelConfigService
::
colonelConfig
(
$params
);
return
$this
->
success
([
"result"
=>
$data
]);
return
$this
->
success
([
"result"
=>
$data
]);
}
}
/**
/**
...
@@ -131,7 +133,7 @@ class ColonelController extends Base
...
@@ -131,7 +133,7 @@ class ColonelController extends Base
{
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
$data
=
PindanActivityInviteOrderService
::
placeOrder
(
$params
);
$data
=
PindanActivityInviteOrderService
::
placeOrder
(
$params
);
return
$this
->
success
([
"result"
=>
$data
]);
return
$this
->
success
([
"result"
=>
$data
]);
}
}
/**
/**
...
@@ -142,17 +144,44 @@ class ColonelController extends Base
...
@@ -142,17 +144,44 @@ class ColonelController extends Base
{
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
$data
=
PindanActivityInviteOrderService
::
refundOrder
(
$params
);
$data
=
PindanActivityInviteOrderService
::
refundOrder
(
$params
);
return
$this
->
success
([
"result"
=>
$data
]);
return
$this
->
success
([
"result"
=>
$data
]);
}
}
/**
/**
* 团长分销任务中心
* 团长分销
,
任务中心
* @throws Exception
* @throws Exception
*/
*/
public
function
task_controlAction
()
public
function
task_controlAction
()
{
{
$params
=
$this
->
params
;
$params
=
$this
->
params
;
$data
=
PindanActivityColonelConfigService
::
getTaskData
(
$params
);
$data
=
PindanActivityColonelConfigService
::
getTaskData
(
$params
);
return
$this
->
success
([
"result"
=>
$data
]);
return
$this
->
success
([
"result"
=>
$data
]);
}
/**
* 团长分销,数据统计
* @throws Exception
*/
public
function
colonel_indexAction
()
{
(
new
ColonelCenterValidate
())
->
validate
();
$params
=
$this
->
params
;
$userId
=
$params
[
"user_id"
];
$wechatInfo
=
UserService
::
userWechatBind
([
"user_id"
=>
$userId
]);
$user
=
[];
if
(
!
empty
(
$wechatInfo
))
{
$user
=
[
"user_id"
=>
$wechatInfo
[
0
][
"user_id"
],
"user_nick"
=>
$wechatInfo
[
0
][
"user_nick"
],
"user_avatar"
=>
$wechatInfo
[
0
][
"user_avatar"
]
];
}
$incomeData
=
PindanActivityInviteOrderService
::
incomeStatistics
([
"user_ids"
=>
[
$userId
]]);
$orderNumData
=
PindanActivityInviteOrderService
::
inviteOrderNumberStatistics
([
"user_ids"
=>
[
$userId
]]);
return
$this
->
success
([
"result"
=>
[
"income"
=>
$incomeData
[
$userId
],
"order_num"
=>
$orderNumData
[
$userId
],
"user"
=>
$user
]]);
}
}
}
}
application/services/marketing/PindanActivityInviteOrderService.php
View file @
ae3ee325
...
@@ -93,30 +93,75 @@ class PindanActivityInviteOrderService
...
@@ -93,30 +93,75 @@ class PindanActivityInviteOrderService
return
true
;
return
true
;
}
}
/**
* 团长分销,昨日收入,总收入
* @param array $params
* @return array
*/
public
static
function
incomeStatistics
(
$params
=
[])
public
static
function
incomeStatistics
(
$params
=
[])
{
{
$userId
=
$params
[
"user_id"
];
$userIds
=
$params
[
"user_ids"
];
$yesterday
=
date
(
"Y-m-d H:i:s"
,
strtotime
(
"-1 day"
));
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$yesterdayRewards
=
ColonelDistributorPayInfo
::
select
([
"reward"
],
[
"date"
=>
$yesterday
,
"colonel_user_id"
=>
$userId
],
[]);
$yesterdayRewards
=
ColonelDistributorPayInfo
::
select
([
"colonel_user_id"
,
"reward"
],
[
"date"
=>
$yesterday
,
"colonel_user_id"
=>
$userIds
],
[]);
$allRewards
=
ColonelDistributorPayInfo
::
select
([
"reward"
],
[
"colonel_user_id"
=>
$userId
],
[]);
$yesterdayData
=
[];
if
(
!
empty
(
$yesterdayRewards
))
{
foreach
(
$yesterdayRewards
as
$item
)
{
$yesterdayData
[
$item
[
"colonel_user_id"
]][]
=
$item
[
"reward"
];
}
}
$yesterdayRewards
=
array_column
(
$yesterdayRewards
,
"reward"
);
$allRewards
=
ColonelDistributorPayInfo
::
select
([
"colonel_user_id"
,
"reward"
],
[
"colonel_user_id"
=>
$userIds
],
[]);
$yesterdayReward
=
array_sum
(
$yesterdayRewards
);
$allData
=
[];
if
(
!
empty
(
$allRewards
))
{
foreach
(
$allRewards
as
$item
)
{
$allData
[
$item
[
"colonel_user_id"
]][]
=
$item
[
"reward"
];
}
}
$allRewards
=
array_column
(
$allRewards
,
"reward"
);
$data
=
[];
$allReward
=
array_sum
(
$allRewards
);
foreach
(
$userIds
as
$userId
)
{
$data
[
$userId
][
"yesterday_reward"
]
=
0
;
$data
[
$userId
][
"all_reward"
]
=
0
;
if
(
!
empty
(
$yesterdayData
[
$userId
]))
{
$data
[
$userId
][
"yesterday_reward"
]
=
sprintf
(
"%.2f"
,
array_sum
(
$yesterdayData
[
$userId
])
/
100
);
}
if
(
!
empty
(
$allData
[
$userId
]))
{
$data
[
$userId
][
"all_reward"
]
=
sprintf
(
"%.2f"
,
array_sum
(
$allData
[
$userId
])
/
100
);
}
}
return
[
"yesterday_reward"
=>
$yesterdayReward
,
"all_reward"
=>
$allReward
]
;
return
$data
;
}
}
/**
* 团长分销,昨日转化单数,总转化单数
* @param array $params
* @return array
*/
public
static
function
inviteOrderNumberStatistics
(
$params
=
[])
public
static
function
inviteOrderNumberStatistics
(
$params
=
[])
{
{
$userIds
=
$params
[
"user_ids"
];
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$yesterdayNums
=
ColonelDistributorInviteOrderNum
::
select
([
"colonel_user_id"
,
"num"
],
[
"date"
=>
$yesterday
,
"colonel_user_id"
=>
$userIds
],
[]);
$yesterdayData
=
array_column
(
$yesterdayNums
,
null
,
"colonel_user_id"
);
$allNums
=
ColonelDistributorInviteOrderNum
::
select
([
"colonel_user_id"
,
"num"
],
[
"colonel_user_id"
=>
$userIds
],
[]);
$allData
=
array_column
(
$allNums
,
null
,
"colonel_user_id"
);
$data
=
[];
foreach
(
$userIds
as
$userId
)
{
$data
[
$userId
][
"yesterday_order_num"
]
=
0
;
$data
[
$userId
][
"all_order_reward"
]
=
0
;
if
(
!
empty
(
$yesterdayData
[
$userId
]))
{
$data
[
$userId
][
"yesterday_order_num"
]
=
$yesterdayData
[
$userId
][
"num"
];
}
}
if
(
!
empty
(
$allData
[
$userId
]))
{
public
static
function
newUserStatistics
(
$params
=
[])
$data
[
$userId
][
"all_order_reward"
]
=
$allData
[
$userId
][
"num"
];
{
}
}
return
$data
;
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment