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
a62f6d1e
Commit
a62f6d1e
authored
Aug 30, 2021
by
pengfei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'colonel' into develop
parents
9ff944e8
c89de689
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
8 deletions
+116
-8
Colonelorder.php
application/modules/Cli/controllers/Colonelorder.php
+109
-1
ColonelService.php
application/services/marketing/ColonelService.php
+7
-7
No files found.
application/modules/Cli/controllers/Colonelorder.php
View file @
a62f6d1e
...
...
@@ -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
))
{
$data
=
$this
->
addIdgenId
(
$colonelPayInfoData
);
try
{
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"
=>
3
*
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
...
...
application/services/marketing/ColonelService.php
View file @
a62f6d1e
...
...
@@ -61,10 +61,10 @@ class ColonelService
* Notes: 查看用户是否已申请
* User: pengfei@yidian-inc.com
* Date: 2021/8/25 11:42 上午
* @param
int
$userId
* @param $userId
* @return array
*/
public
static
function
isApply
(
int
$userId
)
:
array
public
static
function
isApply
(
$userId
)
:
array
{
$applyInfo
=
ColonelDistributorColonelApply
::
getRecord
([
'user_id'
=>
$userId
],
[
'colonel_apply_id'
,
'audit_status'
]);
return
[
...
...
@@ -136,12 +136,12 @@ class ColonelService
* Notes: 团长申请审核
* User: pengfei@yidian-inc.com
* Date: 2021/8/23 1:54 下午
* @param
int
$applyId
* @param
int
$auditStatus
* @param $applyId
* @param $auditStatus
* @return bool
* @throws MarketingException
*/
public
static
function
handleManageAudit
(
int
$applyId
,
int
$auditStatus
)
:
bool
public
static
function
handleManageAudit
(
$applyId
,
$auditStatus
)
:
bool
{
// 审核状态参数检测
if
(
!
in_array
(
$auditStatus
,
[
ColonelDistributorColonelApply
::
STATUS_PASS
,
ColonelDistributorColonelApply
::
STATUS_REJECT
]))
{
...
...
@@ -179,10 +179,10 @@ class ColonelService
* Notes: 获取自提点信息
* User: pengfei@yidian-inc.com
* Date: 2021/8/24 2:40 下午
* @param
int
$applyId
* @param $applyId
* @return array
*/
public
static
function
getTakePlaceInfo
(
int
$applyId
)
:
array
public
static
function
getTakePlaceInfo
(
$applyId
)
:
array
{
$where
=
[
'colonel_apply_id'
=>
$applyId
...
...
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