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
31f89439
Commit
31f89439
authored
Aug 30, 2021
by
pengfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 优化团长分销-计算奖励脚本
parent
7171c691
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
1 deletion
+109
-1
Colonelorder.php
application/modules/Cli/controllers/Colonelorder.php
+109
-1
No files found.
application/modules/Cli/controllers/Colonelorder.php
View file @
31f89439
...
...
@@ -17,7 +17,25 @@ use \App\Models\user\mysql\UserWechatBind;
*/
class
ColonelorderController
extends
Cli
{
public
function
indexAction
()
const
DEFAULT_USER_BATCH_SIZE
=
100
;
public
$today
;
public
$yesterday
;
public
$colonelConfig
;
public
$colonelConfigList
;
public
function
init
()
{
parent
::
init
();
$this
->
today
=
date
(
"Y-m-d"
);
$this
->
yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$this
->
colonelConfig
=
$this
->
getColonelConfig
(
$this
->
yesterday
);
if
(
!
empty
(
$this
->
colonelConfig
))
{
$this
->
colonelConfigList
=
json_decode
(
$this
->
colonelConfig
[
'data'
],
true
);
}
}
public
function
indexBakAction
()
{
$userIdList
=
$this
->
getColonelUserIds
();
ColonelDistributorPayInfo
::
beginTransaction
();
...
...
@@ -95,6 +113,96 @@ class ColonelorderController extends Cli
}
}
public
function
indexAction
()
{
$userIdList
=
$this
->
getColonelUserIds
();
if
(
empty
(
$userIdList
)
||
empty
(
$this
->
colonelConfigList
))
{
return
true
;
}
$userIdList
=
array_chunk
(
$userIdList
,
self
::
DEFAULT_USER_BATCH_SIZE
);
$colonelPayInfoData
=
[];
foreach
(
$userIdList
as
$userIds
)
{
$batchPayInfoData
=
[];
// 完成目标单数
$batchPayInfoData
[]
=
$this
->
getInviteOrderData
(
$userIds
);
// 邀请新用户奖励
$batchPayInfoData
[]
=
$this
->
getInviteNewUserData
(
$userIds
);
$colonelPayInfoData
=
array_merge
(
$colonelPayInfoData
,
$batchPayInfoData
);
}
if
(
!
empty
(
$colonelPayInfoData
))
{
try
{
$data
=
$this
->
addIdgenId
(
$colonelPayInfoData
);
ColonelDistributorPayInfo
::
beginTransaction
();
if
(
!
$this
->
addColonelDistributorPayInfo
(
$data
))
{
throw
new
\Exception
(
sprintf
(
"写入错误参数 %s"
,
json_encode
(
$data
)));
}
if
(
!
ColonelDistributorPayInfo
::
commit
())
{
throw
new
\Exception
(
sprintf
(
"事务提交失败 %s"
,
json_encode
(
$data
)));
}
}
catch
(
\Exception
$e
)
{
ColonelDistributorPayInfo
::
rollback
();
FileLog
::
info
(
"add_colonel_distributor_pay_info"
,
$e
->
getMessage
());
}
}
return
true
;
}
/**
* 获取新用户奖励
* @param $yesterday
* @return array
*/
public
function
getInviteNewUserData
(
$userIds
)
{
$inviteNewUserList
=
$this
->
getInviteNewUserList
(
$userIds
,
$this
->
today
);
$inviteOrderData
=
[];
if
(
!
empty
(
$inviteNewUserList
))
{
$userNickList
=
$this
->
getUserList
(
array_column
(
$inviteNewUserList
,
"user_id"
));
foreach
(
$inviteNewUserList
as
$newUser
)
{
$payInfo
=
[
"colonel_user_id"
=>
$newUser
[
"inviter_user_id"
],
"date"
=>
$this
->
yesterday
,
"type"
=>
ColonelDistributorPayInfo
::
TYPE_NEW_USER
,
"reward"
=>
5
*
100
,
"finish_num"
=>
1
,
"invite_user_id"
=>
$newUser
[
"user_id"
],
"invite_user_nick"
=>
empty
(
$userNickList
[
$newUser
[
"user_id"
]][
"user_nick"
])
?
""
:
$userNickList
[
$newUser
[
"user_id"
]][
"user_nick"
],
];
$inviteOrderData
[]
=
$payInfo
;
}
}
return
$inviteOrderData
;
}
/**
* 获取完成目标单数奖励
* @param $yesterday
* @return array
*/
public
function
getInviteOrderData
(
$userIds
)
{
//完成目标单数
$inviteOrderNumList
=
$this
->
getInviteOrderNum
(
$userIds
,
$this
->
yesterday
,
$this
->
today
);
$inviteOrderData
=
[];
foreach
(
$inviteOrderNumList
as
$orderNum
)
{
foreach
(
$this
->
colonelConfigList
as
$config
)
{
if
(
!
empty
(
$orderNum
[
"num"
])
&&
$orderNum
[
"num"
]
>=
$config
[
"assess_order_num"
])
{
$payInfo
=
[
"colonel_user_id"
=>
$orderNum
[
"colonel_user_id"
],
"date"
=>
$this
->
yesterday
,
"type"
=>
ColonelDistributorPayInfo
::
TYPE_FINISH_TARGET
,
"reward"
=>
$config
[
"reward_amount"
]
*
100
,
"finish_num"
=>
$config
[
"assess_order_num"
],
"invite_user_id"
=>
0
,
"invite_user_nick"
=>
""
,
];
$inviteOrderData
[]
=
$payInfo
;
}
}
}
return
$inviteOrderData
;
}
/**
* 团长任务配置
* @param $yesterday
...
...
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