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
5d81489c
Commit
5d81489c
authored
Aug 27, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 团长分销账单详情
parent
2facb1b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
235 additions
and
2 deletions
+235
-2
Colonelorder.php
application/modules/Cli/controllers/Colonelorder.php
+216
-0
PindanActivityInviteOrderService.php
...n/services/marketing/PindanActivityInviteOrderService.php
+19
-2
No files found.
application/modules/Cli/controllers/Colonelorder.php
0 → 100644
View file @
5d81489c
<?php
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpUtils\Log\FileLog
;
use
App\Base\Cli
;
use
\App\Models\marketing\mysql\ColonelDistributorColonel
;
use
\App\Models\marketing\mysql\ColonelDistributorInviteOrder
;
use
\App\Models\marketing\mysql\ColonelDistributorConfig
;
use
\App\Models\marketing\mysql\ColonelDistributorInviteOrderNum
;
use
\App\Models\marketing\mysql\ColonelDistributorPayInfo
;
use
\App\Exception\custom\InterfaceException
;
use
Api\PhpUtils\Http\HttpUtil
;
use
\App\Models\user\mysql\UserWechatBind
;
/**
* php public/cli.php colonelorder index
*/
class
ColonelorderController
extends
Cli
{
public
function
indexAction
()
{
$userIds
=
$this
->
getColonelUserIds
();
ColonelDistributorPayInfo
::
beginTransaction
();
if
(
!
empty
(
$userIds
))
{
$today
=
date
(
"Y-m-d"
);
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$startTime
=
$yesterday
.
" 16:00:00"
;
$endTime
=
$today
.
" 10:00:00"
;
$colonelConfig
=
$this
->
getColonelConfig
(
$yesterday
);
$insertData
=
[];
if
(
!
empty
(
$colonelConfig
[
"data"
]))
{
$configList
=
json_decode
(
$colonelConfig
[
"data"
],
true
);
//完成目标单数
$inviteOrderNumList
=
$this
->
getInviteOrderNum
(
$userIds
,
$yesterday
,
$today
);
foreach
(
$inviteOrderNumList
as
$orderNum
)
{
foreach
(
$configList
as
$config
)
{
if
(
!
empty
(
$orderNum
[
"num"
])
&&
$orderNum
[
"num"
]
>=
$config
[
"assess_order_num"
])
{
$payInfo
=
[
"colonel_user_id"
=>
$orderNum
[
"colonel_user_id"
],
"date"
=>
$yesterday
,
"type"
=>
ColonelDistributorPayInfo
::
TYPE_FINISH_TARGET
,
"reward"
=>
$config
[
"reward_amount"
]
*
100
,
"finish_num"
=>
$config
[
"assess_order_num"
],
"invite_user_id"
=>
0
,
"invite_user_nick"
=>
""
,
];
$insertData
[]
=
$payInfo
;
}
}
}
//新用户奖励
$inviteNewUserList
=
$this
->
getInviteNewUserList
(
$userIds
,
$today
);
$colonelUserIds
=
array_column
(
$inviteNewUserList
,
"user_id"
);
$userNickList
=
$this
->
getUserList
(
$colonelUserIds
);
if
(
!
empty
(
$inviteNewUserList
))
{
foreach
(
$inviteNewUserList
as
$newUser
)
{
$payInfo
=
[
"colonel_user_id"
=>
$newUser
[
"inviter_user_id"
],
"date"
=>
$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"
],
];
$insertData
[]
=
$payInfo
;
}
}
}
if
(
!
empty
(
$insertData
))
{
$data
=
$this
->
addIdgenId
(
$insertData
);
$res
=
$this
->
addColonelDistributorPayInfo
(
$data
);
if
(
$res
===
false
)
{
ColonelDistributorPayInfo
::
rollback
();
FileLog
::
info
(
"add_colonel_distributor_pay_info"
,
sprintf
(
"写入错误参数 %s"
,
json_encode
(
$data
)));
}
}
}
if
(
!
ColonelDistributorPayInfo
::
commit
())
{
ColonelDistributorPayInfo
::
rollback
();
}
}
/**
* 团长任务配置
* @param $yesterday
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
function
getColonelConfig
(
$yesterday
)
{
$type
=
empty
(
$params
[
"type"
])
?
ColonelDistributorConfig
::
TYPE_COLONEL
:
$params
[
"type"
];
$config
=
ColonelDistributorConfig
::
getRecord
([
"date"
=>
$yesterday
,
"type"
=>
$type
]);
if
(
empty
(
$config
))
{
$config
=
ColonelDistributorConfig
::
getRecord
([
"date[<=]"
=>
$yesterday
,
"ORDER"
=>
[
"date"
=>
"DESC"
],
"LIMIT"
=>
1
]);
}
return
$config
;
}
/**
* 团长user_id
* @return array
*/
public
function
getColonelUserIds
()
{
$colonelRes
=
ColonelDistributorColonel
::
select
([
"user_id"
]);
$userIds
=
[];
if
(
!
empty
(
$colonelRes
))
{
$userIds
=
array_column
(
$colonelRes
,
"user_id"
);
}
return
$userIds
;
}
public
function
getInviteOrder
(
$colonelUserIds
,
$startTime
,
$endTime
)
{
return
ColonelDistributorInviteOrder
::
select
([
"colonel_user_id"
,
"user_id"
,
"is_refund"
,
"create_time"
],
[
"colonel_user_id"
=>
$colonelUserIds
,
"create_time[>=]"
=>
$startTime
,
"create_time[<=]"
=>
$endTime
,
"is_refund"
=>
0
,
],
[]);
}
/**
* 获取order num
* @param $colonelUserIds
* @param $startTime
* @param $endTime
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
function
getInviteOrderNum
(
$colonelUserIds
,
$startTime
,
$endTime
)
{
return
ColonelDistributorInviteOrderNum
::
select
([
"colonel_user_id"
,
"num"
,
"date"
],
[
"colonel_user_id"
=>
$colonelUserIds
,
"date[>=]"
=>
$startTime
,
"date[<=]"
=>
$endTime
,
],
[]);
}
/**
* 获取有效新用户信息
* @param $userIds
* @param $date
* @return array|mixed
* @throws InterfaceException
*/
public
function
getInviteNewUserList
(
$userIds
,
$date
)
{
$url
=
config
(
'interface'
,
'coupon.background.wx_invite_relation_list_by_user_ids'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$res
=
HttpUtil
::
get
(
$url
,
[
"user_ids"
=>
$userIds
,
"date"
=>
$date
]);
if
(
!
empty
(
$res
[
"response"
][
"result"
]))
{
$res
=
array_column
(
$res
[
"response"
][
"result"
],
null
,
"user_id"
);
return
array_values
(
$res
);
}
return
[];
}
/**
* 给数据整理 colonel_distributor_pay_info_id
* @param $data
* @param string $type
* @return mixed
*/
public
function
addIdgenId
(
$data
,
$type
=
"goods"
)
{
$count
=
count
(
$data
);
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
$type
,
'number'
=>
00
,
"count"
=>
$count
]]);
$ids
=
$res
[
'id_datetime'
][
$type
]
??
[];
foreach
(
$data
as
$key
=>
$item
)
{
$data
[
$key
][
"colonel_distributor_pay_info_id"
]
=
$ids
[
$key
];
}
return
$data
;
}
/**
* 用户信息,获取昵称
* @param $userIds
* @return \Api\PhpUtils\Mysql\MysqlBase|array
*/
public
function
getUserList
(
$userIds
)
{
$list
=
UserWechatBind
::
select
([
"user_id"
,
"user_nick"
],
[
"user_id"
=>
$userIds
],
[]);
if
(
!
empty
(
$list
))
{
$list
=
array_column
(
$list
,
null
,
"user_id"
);
}
return
$list
;
}
/**
* 写入数据
* @param $data
* @return \Api\PhpUtils\Mysql\MysqlBase
*/
public
function
addColonelDistributorPayInfo
(
$data
)
{
return
ColonelDistributorPayInfo
::
save
(
$data
);
}
}
\ No newline at end of file
application/services/marketing/PindanActivityInviteOrderService.php
View file @
5d81489c
...
@@ -32,9 +32,18 @@ class PindanActivityInviteOrderService
...
@@ -32,9 +32,18 @@ class PindanActivityInviteOrderService
return
true
;
return
true
;
}
}
$hour
=
date
(
"H"
);
if
(
$hour
<
10
&&
$hour
>
0
)
{
$date
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
}
elseif
(
$hour
>
16
)
{
$date
=
date
(
"Y-m-d"
);
}
else
{
$date
=
date
(
"Y-m-d"
);
}
$inviteOrderNumData
=
[
$inviteOrderNumData
=
[
"colonel_user_id"
=>
$params
[
"colonel_user_id"
],
"colonel_user_id"
=>
$params
[
"colonel_user_id"
],
"date"
=>
date
(
"Y-m-d"
)
,
"date"
=>
$date
,
];
];
$inviteOrderNum
=
ColonelDistributorInviteOrderNum
::
selectMaster
(
"*"
,
$inviteOrderNumData
,
[]);
$inviteOrderNum
=
ColonelDistributorInviteOrderNum
::
selectMaster
(
"*"
,
$inviteOrderNumData
,
[]);
...
@@ -73,9 +82,17 @@ class PindanActivityInviteOrderService
...
@@ -73,9 +82,17 @@ class PindanActivityInviteOrderService
"order_id"
=>
$orderId
,
"order_id"
=>
$orderId
,
];
];
$hour
=
date
(
"H"
);
if
(
$hour
<
10
&&
$hour
>
0
)
{
$date
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
}
elseif
(
$hour
>
16
)
{
$date
=
date
(
"Y-m-d"
);
}
else
{
$date
=
date
(
"Y-m-d"
);
}
$inviteOrderNumData
=
[
$inviteOrderNumData
=
[
"colonel_user_id"
=>
$inviteOrder
[
0
][
"colonel_user_id"
],
"colonel_user_id"
=>
$inviteOrder
[
0
][
"colonel_user_id"
],
"date"
=>
date
(
"Y-m-d"
)
,
"date"
=>
$date
,
];
];
ColonelDistributorInviteOrder
::
beginTransaction
();
ColonelDistributorInviteOrder
::
beginTransaction
();
...
...
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