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
4f15265b
Commit
4f15265b
authored
Sep 03, 2021
by
pengfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 团长分销-奖励结算脚本
parent
5b271e60
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
297 additions
and
192 deletions
+297
-192
ColonelDistributorColonel.php
...tion/models/marketing/mysql/ColonelDistributorColonel.php
+6
-0
ColonelDistributorInviteOrderNum.php
...dels/marketing/mysql/ColonelDistributorInviteOrderNum.php
+6
-1
ColonelDistributorPayInfo.php
...tion/models/marketing/mysql/ColonelDistributorPayInfo.php
+7
-2
Colonelorder.php
application/modules/Job/controllers/Colonelorder.php
+139
-121
Colonelwallet.php
application/modules/Job/controllers/Colonelwallet.php
+100
-64
PindanActivityColonelConfigService.php
...services/marketing/PindanActivityColonelConfigService.php
+24
-1
FileLog.php
vendor/api/php_utils/src/Log/FileLog.php
+15
-3
No files found.
application/models/marketing/mysql/ColonelDistributorColonel.php
View file @
4f15265b
...
...
@@ -20,6 +20,12 @@ class ColonelDistributorColonel extends MysqlBase
const
DEFAULT_COLUMN
=
[
'colonel_id'
,
'user_id'
,
'take_place_id'
,
'phone'
,
'contact_name'
,
'colonel_source'
];
public
static
function
getColonelUserIds
()
{
$colonelUserData
=
ColonelDistributorColonel
::
select
([
'user_id'
]);
return
array_column
((
array
)
$colonelUserData
,
'user_id'
);
}
public
static
function
getRecord
(
array
$where
,
$column
=
'*'
)
{
return
self
::
get
(
$column
,
$where
);
...
...
application/models/marketing/mysql/ColonelDistributorInviteOrderNum.php
View file @
4f15265b
...
...
@@ -18,6 +18,11 @@ class ColonelDistributorInviteOrderNum extends MysqlBase
return
self
::
get
(
$columns
,
$where
,
$options
);
}
public
static
function
getRecords
(
array
$where
,
$column
=
'*'
)
{
return
(
array
)
self
::
select
(
$column
,
$where
);
}
public
static
function
getRecordMaster
(
$where
,
$columns
=
[],
$options
=
[])
{
if
(
empty
(
$columns
))
{
...
...
@@ -48,4 +53,4 @@ class ColonelDistributorInviteOrderNum extends MysqlBase
{
return
self
::
delete
(
$where
);
}
}
\ No newline at end of file
}
application/models/marketing/mysql/ColonelDistributorPayInfo.php
View file @
4f15265b
...
...
@@ -21,6 +21,11 @@ class ColonelDistributorPayInfo extends MysqlBase
self
::
TYPE_FINISH_TARGET
=>
"完成目标单数"
,
];
public
static
function
getRecords
(
array
$where
,
$column
=
'*'
)
{
return
(
array
)
self
::
select
(
$column
,
$where
);
}
public
static
function
getRecord
(
$where
,
$columns
=
[],
$options
=
[])
{
if
(
empty
(
$columns
))
{
...
...
@@ -44,7 +49,7 @@ class ColonelDistributorPayInfo extends MysqlBase
public
static
function
updateRecord
(
$columns
,
$where
)
{
return
self
::
update
(
$columns
,
$where
);
return
(
int
)
self
::
update
(
$columns
,
$where
);
}
public
static
function
save
(
$data
,
$where
=
[],
$options
=
[])
...
...
@@ -59,4 +64,4 @@ class ColonelDistributorPayInfo extends MysqlBase
{
return
self
::
delete
(
$where
);
}
}
\ No newline at end of file
}
application/modules/Job/controllers/Colonelorder.php
View file @
4f15265b
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 2:23 下午
*/
use
App\Base\Job
;
use
Api\PhpServices\Idgen\Idgen
;
...
...
@@ -10,141 +15,147 @@ use App\Models\marketing\mysql\ColonelDistributorPayInfo;
use
App\Exception\custom\InterfaceException
;
use
Api\PhpUtils\Http\HttpUtil
;
use
App\Models\user\mysql\UserWechatBind
;
use
App\Services\marketing\PindanActivityColonelConfigService
;
class
ColonelorderController
extends
Job
{
const
DEFAULT_USER_BATCH_SIZE
=
100
;
const
REWARD_UNIT
=
100
;
// 奖励单位: 分
const
INVITE_NEW_USER_REWARD
=
3
*
self
::
REWARD_UNIT
;
// 邀请新用户奖励
const
DEFAULT_USER_BATCH_SIZE
=
100
;
// 批量处理数据条数
public
$
today
;
public
$
yesterday
;
public
$
colonelConfig
;
public
$
colonelConfigList
;
public
$
colonelConfigList
;
// 活动配置
public
$
settlementDate
;
// 活动结算日
public
$
startTime
;
// 活动结算日-开始时间
public
$
endTime
;
// 活动结算日-结束时间
/**
* Notes: 初始化-读取配置
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:13 下午
*/
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
);
$timeRange
=
PindanActivityColonelConfigService
::
getSettlementTimeRange
();
$this
->
settlementDate
=
$timeRange
[
'date'
];
$this
->
startTime
=
$timeRange
[
'start_time'
];
$this
->
endTime
=
$timeRange
[
'end_time'
];
$colonelConfig
=
$this
->
getColonelConfig
(
$this
->
settlementDate
);
if
(
!
empty
(
$colonelConfig
[
'data'
]))
{
$this
->
colonelConfigList
=
json_decode
(
$colonelConfig
[
'data'
],
true
);
}
}
/**
* Notes: 计算奖励脚本
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:05 下午
* @throws InterfaceException
*/
public
function
indexAction
()
{
FileLog
::
info
(
"colonel_distributor_order"
,
'团长分销-计算奖励脚本:start'
);
$userIdList
=
$this
->
getColonelUserIds
();
if
(
!
empty
(
$userIdList
))
{
$this
->
loggerInfo
(
'start'
);
if
(
$userIdList
=
ColonelDistributorColonel
::
getColonelUserIds
())
{
$userIdList
=
array_chunk
(
$userIdList
,
self
::
DEFAULT_USER_BATCH_SIZE
);
$colonelPayInfoData
=
[];
foreach
(
$userIdList
as
$userIds
)
{
// 完成目标单数
if
(
$inviteOrderData
=
$this
->
getInviteOrderData
(
$userIds
))
{
$colonelPayInfoData
=
array_merge
(
$colonelPayInfoData
,
$inviteOrderData
);
}
// 邀请新用户奖励
if
(
$inviteNewUserData
=
$this
->
getInviteNewUserData
(
$userIds
))
{
$colonelPayInfoData
=
array_merge
(
$colonelPayInfoData
,
$inviteNewUserData
);
}
$this
->
getInviteOrderData
(
$userIds
,
$colonelPayInfoData
);
// 完成目标单数
$this
->
getInviteNewUserData
(
$userIds
,
$colonelPayInfoData
);
// 邀请新用户奖励
}
$this
->
handleSavePayInfo
(
$colonelPayInfoData
);
}
FileLog
::
info
(
"colonel_distributor_order"
,
'团长分销-计算奖励脚本:end'
);
echo
"success"
;
$this
->
loggerInfo
(
'end'
);
}
/**
* 保存奖励信息
* @param $yesterday
* @return true
* Notes: 保存奖励信息
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:34 下午
* @param $colonelPayInfoData
*/
p
ublic
function
handleSavePayInfo
(
$colonelPayInfoData
)
p
rivate
function
handleSavePayInfo
(
$colonelPayInfoData
)
{
FileLog
::
info
(
"colonel_distributor_order"
,
'团长分销-计算奖励脚本:
colonelPayInfoCount='
.
count
(
$colonelPayInfoData
));
$this
->
loggerInfo
(
'
colonelPayInfoCount='
.
count
(
$colonelPayInfoData
));
if
(
!
empty
(
$colonelPayInfoData
))
{
$data
=
$this
->
addIdgenId
(
$colonelPayInfoData
);
$data
=
$this
->
getFormatPayInfoData
(
$colonelPayInfoData
);
try
{
ColonelDistributorPayInfo
::
beginTransaction
();
if
(
!
$this
->
addColonelDistributorPayInfo
(
$data
))
{
throw
new
\
Exception
(
sprintf
(
"写入错误参数 %s"
,
json_encode
(
$data
)));
throw
new
Exception
(
sprintf
(
"写入错误参数 %s"
,
json_encode
(
$data
)));
}
if
(
!
ColonelDistributorPayInfo
::
commit
())
{
throw
new
\
Exception
(
sprintf
(
"事务提交失败 %s"
,
json_encode
(
$data
)));
throw
new
Exception
(
sprintf
(
"事务提交失败 %s"
,
json_encode
(
$data
)));
}
}
catch
(
\
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
ColonelDistributorPayInfo
::
rollback
();
FileLog
::
info
(
"add_colonel_distributor_pay_info"
,
$e
->
getMessage
());
$this
->
loggerError
(
'error='
.
$e
->
getMessage
());
}
}
return
true
;
}
/**
* 获取新用户奖励
* @param $yesterday
* @return array
* Notes: 获取新用户奖励
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:47 下午
* @param $userIds
* @param $colonelPayInfoData
* @throws InterfaceException
*/
p
ublic
function
getInviteNewUserData
(
$userIds
)
p
rivate
function
getInviteNewUserData
(
$userIds
,
&
$colonelPayInfoData
)
{
$inviteNewUserList
=
$this
->
getInviteNewUserList
(
$userIds
,
$this
->
today
);
$inviteOrderData
=
[];
if
(
!
empty
(
$inviteNewUserList
))
{
if
(
$inviteNewUserList
=
$this
->
getInviteNewUserList
(
$userIds
))
{
$userNickList
=
$this
->
getUserList
(
array_column
(
$inviteNewUserList
,
"user_id"
));
foreach
(
$inviteNewUserList
as
$newUser
)
{
$payInfo
=
[
"colonel_user_id"
=>
$newUser
[
"inviter_user_id"
],
"date"
=>
$this
->
yesterday
,
"date"
=>
$this
->
settlementDate
,
"type"
=>
ColonelDistributorPayInfo
::
TYPE_NEW_USER
,
"reward"
=>
3
*
100
,
"reward"
=>
self
::
INVITE_NEW_USER_REWARD
,
"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"
],
];
$
inviteOrder
Data
[]
=
$payInfo
;
$
colonelPayInfo
Data
[]
=
$payInfo
;
}
}
return
$inviteOrderData
;
}
/**
* 获取完成目标单数奖励
* @param $yesterday
* @return array
* Notes: 获取完成目标单数奖励
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:47 下午
* @param $userIds
* @param $colonelPayInfoData
*/
p
ublic
function
getInviteOrderData
(
$userIds
)
p
rivate
function
getInviteOrderData
(
$userIds
,
&
$colonelPayInfoData
)
{
//完成目标单数
$inviteOrderData
=
[];
if
(
empty
(
$this
->
colonelConfigList
))
{
return
$inviteOrderData
;
}
$inviteOrderNumList
=
$this
->
getInviteOrderNum
(
$userIds
,
$this
->
yesterday
,
$this
->
today
);
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
;
$inviteOrderNumList
=
$this
->
getInviteOrderNum
(
$userIds
,
$this
->
settlementDate
);
foreach
(
$inviteOrderNumList
as
$orderNum
)
{
foreach
(
$this
->
colonelConfigList
as
$config
)
{
if
(
$orderNum
[
"num"
]
>=
$config
[
"assess_order_num"
])
{
$payInfo
=
[
"colonel_user_id"
=>
$orderNum
[
"colonel_user_id"
],
"date"
=>
$this
->
settlementDate
,
"type"
=>
ColonelDistributorPayInfo
::
TYPE_FINISH_TARGET
,
"reward"
=>
$config
[
"reward_amount"
]
*
self
::
REWARD_UNIT
,
"finish_num"
=>
$config
[
"assess_order_num"
],
"invite_user_id"
=>
0
,
"invite_user_nick"
=>
""
,
];
$colonelPayInfoData
[]
=
$payInfo
;
}
}
}
}
return
$inviteOrderData
;
}
/**
* 团长任务配置
* @param $yesterday
* @return
\Api\PhpUtils\Mysql\MysqlBase
* @return
array
*/
p
ublic
function
getColonelConfig
(
$yesterday
)
p
rivate
function
getColonelConfig
(
$yesterday
)
:
array
{
$type
=
empty
(
$params
[
"type"
])
?
ColonelDistributorConfig
::
TYPE_COLONEL
:
$params
[
"type"
];
$config
=
ColonelDistributorConfig
::
getRecord
([
"date"
=>
$yesterday
,
"type"
=>
$type
]);
...
...
@@ -155,79 +166,63 @@ class ColonelorderController extends Job
"LIMIT"
=>
1
]);
}
return
$config
;
}
/**
* 团长user_id
* @return array
*/
public
function
getColonelUserIds
()
{
$colonelRes
=
ColonelDistributorColonel
::
select
([
"user_id"
],
[
"LIMIT"
=>
10000000
]);
$userIds
=
[];
if
(
!
empty
(
$colonelRes
))
{
$userIds
=
array_column
(
$colonelRes
,
"user_id"
);
}
return
$userIds
;
return
(
array
)
$config
;
}
/**
* 获取order num
* @param $colonelUserIds
* @param $startTime
* @param $endTime
* @return \Api\PhpUtils\Mysql\MysqlBase
* @param $date
* @return array
*/
p
ublic
function
getInviteOrderNum
(
$colonelUserIds
,
$startTime
,
$endTime
)
p
rivate
function
getInviteOrderNum
(
$colonelUserIds
,
$date
)
:
array
{
return
ColonelDistributorInviteOrderNum
::
select
(
[
"colonel_user_id"
,
"num"
,
"date"
],
return
ColonelDistributorInviteOrderNum
::
getRecords
(
[
"colonel_user_id"
=>
$colonelUserIds
,
"date[>=]"
=>
$startTime
,
"date[<]"
=>
$endTime
,
"date"
=>
$date
,
],
[]
[
"colonel_user_id"
,
"num"
]
);
}
/**
* 获取有效新用户信息
* Notes: 获取有效新用户信息
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:03 下午
* @param $userIds
* @param $date
* @return array|mixed
* @return array
* @throws InterfaceException
*/
p
ublic
function
getInviteNewUserList
(
$userIds
,
$date
)
p
rivate
function
getInviteNewUserList
(
$userIds
)
:
array
{
$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
);
$res
=
HttpUtil
::
get
(
$url
,
[
'user_ids'
=>
$userIds
,
'start_time'
=>
$this
->
startTime
,
'end_time'
=>
$this
->
endTime
]);
if
(
!
empty
(
$res
[
'response'
][
'result'
]))
{
return
array_values
(
array_column
(
$res
[
'response'
][
'result'
],
null
,
'user_id'
));
}
return
[];
}
/**
* 给数据整理 colonel_distributor_pay_info_id
* Notes: 获取pay_info数据
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:07 下午
* @param $data
* @param string $type
* @return mixed
* @return array
*/
p
ublic
function
addIdgenId
(
$data
,
$type
=
"goods"
)
p
rivate
function
getFormatPayInfoData
(
$data
)
:
array
{
$count
=
count
(
$data
);
$res
=
Idgen
::
get
(
appConfig
(
'idgen.partner'
),
appConfig
(
'idgen.key'
),
[],
[[
"type"
=>
$type
,
"type"
=>
"goods"
,
'number'
=>
00
,
"count"
=>
$count
]]);
$ids
=
$res
[
'id_datetime'
][
$type
]
??
[];
$ids
=
$res
[
'id_datetime'
][
"goods"
]
??
[];
foreach
(
$data
as
$key
=>
$item
)
{
$data
[
$key
][
"colonel_distributor_pay_info_id"
]
=
$ids
[
$key
];
}
...
...
@@ -235,26 +230,49 @@ class ColonelorderController extends Job
}
/**
* 用户信息,获取昵称
* Notes: 用户信息,获取昵称
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:09 下午
* @param $userIds
* @return
\Api\PhpUtils\Mysql\MysqlBase|
array
* @return array
*/
p
ublic
function
getUserList
(
$userIds
)
p
rivate
function
getUserList
(
$userIds
)
:
array
{
$list
=
UserWechatBind
::
select
([
"user_id"
,
"user_nick"
],
[
"user_id"
=>
$userIds
],
[]);
if
(
!
empty
(
$list
))
{
$list
=
array_column
(
$list
,
null
,
"user_id"
);
}
return
$list
;
$list
=
UserWechatBind
::
select
([
'user_id'
,
'user_nick'
],
[
'user_id'
=>
$userIds
],
[]);
return
array_column
((
array
)
$list
,
null
,
'user_id'
);
}
/**
* 写入数据
* Notes: 写入数据
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:10 下午
* @param $data
* @return \Api\PhpUtils\Mysql\MysqlBase
* @return bool
*/
private
function
addColonelDistributorPayInfo
(
$data
)
:
bool
{
return
(
int
)
ColonelDistributorPayInfo
::
save
(
$data
);
}
/**
* Notes: 记录 info 日志
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:10 下午
* @param $log
*/
private
function
loggerInfo
(
$log
)
{
FileLog
::
info
(
"colonel_distributor_order"
,
'colonel_distributor_order:'
.
$log
,
false
,
true
);
}
/**
* Notes: 记录 error 日志
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:10 下午
* @param $log
*/
p
ublic
function
addColonelDistributorPayInfo
(
$data
)
p
rivate
function
loggerError
(
$log
)
{
return
ColonelDistributorPayInfo
::
save
(
$data
);
FileLog
::
info
(
"colonel_distributor_order"
,
'colonel_distributor_order:'
.
$log
,
false
,
true
);
}
}
\ No newline at end of file
}
application/modules/Job/controllers/Colonelwallet.php
View file @
4f15265b
<?php
/**
* Created by PhpStorm.
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 2:23 下午
*/
use
App\Base\Job
;
use
Api\PhpUtils\Log\FileLog
;
...
...
@@ -8,12 +13,22 @@ use Api\PhpUtils\Http\HttpUtil;
class
ColonelwalletController
extends
Job
{
const
CAPITAL_POOL_ID
=
2
;
// 资金池id
const
CAPITAL_POOL_OP
=
200
;
//200:团长奖励
const
WALLET_SERVICE_NAME
=
11
;
// 10生活圈优惠券,11营销活动
const
WALLET_SOURCE_NAME
=
1
;
//使用方名,1生活圈,2主端
/**
* Notes: 奖励结算脚本
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 6:03 下午
* @throws InterfaceException
*/
public
function
indexAction
()
{
FileLog
::
info
(
"colonel_distributor_wallet"
,
'团长分销-奖励钱包脚本:start'
);
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$payInfoList
=
$this
->
getPayInfo
(
$yesterday
);
FileLog
::
info
(
"colonel_distributor_wallet"
,
'团长分销-奖励钱包脚本:payInfoCount='
.
count
(
$payInfoList
));
$this
->
loggerInfo
(
'start'
);
$payInfoList
=
$this
->
getPayInfoList
();
$this
->
loggerInfo
(
'payInfoCount='
.
count
(
$payInfoList
));
if
(
!
empty
(
$payInfoList
))
{
if
(
$this
->
deductingInventory
(
$payInfoList
))
{
if
(
$this
->
toWallet
(
$payInfoList
))
{
...
...
@@ -21,115 +36,136 @@ class ColonelwalletController extends Job
}
}
}
FileLog
::
info
(
"colonel_distributor_wallet"
,
'团长分销-奖励钱包脚本:end'
);
echo
"success"
;
$this
->
loggerInfo
(
'end'
);
}
/**
* colonel_distributor_pay_info 数据
* @param $date
* @return array
* Notes: 结算写入钱包
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 6:04 下午
* @param $payInfoList
* @return bool
* @throws InterfaceException
*/
p
ublic
function
getPayInfo
(
$date
)
p
rivate
function
toWallet
(
$payInfoList
)
:
bool
{
$list
=
ColonelDistributorPayInfo
::
select
(
"*"
,
[
"date"
=>
$date
,
'status'
=>
ColonelDistributorPayInfo
::
STATUS_NOT_USE
],
[]);
$data
=
[];
if
(
!
empty
(
$list
))
{
foreach
(
$list
as
$item
)
{
//去重
$key
=
$item
[
"colonel_user_id"
]
.
$item
[
"date"
]
.
$item
[
"type"
]
.
$item
[
"finish_num"
];
$data
[
$key
]
=
$item
;
}
$data
=
array_values
(
$data
);
}
return
$data
;
}
/**
* 写入钱包
*/
public
function
toWallet
(
$payInfoList
)
{
$url
=
config
(
'interface'
,
'wallet.account.transfer'
);
if
(
empty
(
$url
))
{
if
(
!
$url
=
config
(
'interface'
,
'wallet.account.transfer'
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$data
=
[];
foreach
(
$payInfoList
as
$payInfo
)
{
if
(
$payInfo
[
"type"
]
==
ColonelDistributorPayInfo
::
TYPE_NEW_USER
)
{
$desc
=
"邀请新用户("
.
$payInfo
[
"invite_user_nick"
]
.
")完成下单奖励"
;
}
if
(
$payInfo
[
"type"
]
==
ColonelDistributorPayInfo
::
TYPE_FINISH_TARGET
)
{
$desc
=
"完成"
.
$payInfo
[
"finish_num"
]
.
"单用户下单奖励"
;
}
$tmp
=
[];
$tmp
[
"user_id"
]
=
$payInfo
[
"colonel_user_id"
];
$tmp
[
"service_name"
]
=
11
;
//服务名字,10生活圈优惠券,11营销活动
$tmp
[
"source_name"
]
=
1
;
//使用方名,1生活圈,2主端
$tmp
[
"service_name"
]
=
self
::
WALLET_SERVICE_NAME
;
$tmp
[
"source_name"
]
=
self
::
WALLET_SOURCE_NAME
;
$tmp
[
"third_order_id"
]
=
$payInfo
[
"colonel_distributor_pay_info_id"
];
$tmp
[
"third_order_id_type"
]
=
$payInfo
[
"type"
];
$tmp
[
"third_order_desc"
]
=
$desc
;
$tmp
[
"third_order_desc"
]
=
self
::
getThirdOrderDesc
(
$payInfo
)
;
$tmp
[
"amount"
]
=
$payInfo
[
"reward"
];
$tmp
[
"extra"
]
=
$payInfo
;
$data
[]
=
$tmp
;
}
$res
=
HttpUtil
::
post
(
$url
,
[
"list"
=>
$data
]);
if
(
$res
[
'code'
]
==
0
&&
isset
(
$res
[
'response'
][
"result"
]))
{
$date
=
date
(
"Y-m-d H:i:s"
);
FileLog
::
info
(
"colonel_distributor_to_wallet"
,
$date
.
" 写入钱包成功"
);
if
(
!
empty
(
$res
[
'response'
][
"result"
])
&&
$res
[
'code'
]
==
0
)
{
$this
->
loggerInfo
(
'写入钱包成功'
);
return
true
;
}
else
{
$msg
=
json_encode
([
"list"
=>
$data
]);
FileLog
::
error
(
"colonel_distributor_to_wallet"
,
$msg
,
null
,
'bp-server@yidian-inc.com'
);
$this
->
loggerError
(
$msg
);
return
false
;
}
}
/**
* 资金池授予用户奖励
* Notes: 资金池授予用户奖励
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 6:04 下午
* @param $payInfoList
* @return bool
* @throws InterfaceException
*/
p
ublic
function
deductingInventory
(
$payInfoList
)
p
rivate
function
deductingInventory
(
$payInfoList
)
:
bool
{
$url
=
config
(
'interface'
,
'coupon.capitalpool.grant_user_amount'
);
if
(
empty
(
$url
))
{
if
(
!
$url
=
config
(
'interface'
,
'coupon.capitalpool.grant_user_amount'
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$data
[
"capital_pool_id"
]
=
2
;
$data
[
"capital_pool_id"
]
=
self
::
CAPITAL_POOL_ID
;
foreach
(
$payInfoList
as
$payInfo
)
{
if
(
$payInfo
[
"type"
]
==
ColonelDistributorPayInfo
::
TYPE_NEW_USER
)
{
$desc
=
"邀请新用户("
.
$payInfo
[
"invite_user_nick"
]
.
")完成下单奖励"
;
}
if
(
$payInfo
[
"type"
]
==
ColonelDistributorPayInfo
::
TYPE_FINISH_TARGET
)
{
$desc
=
"完成"
.
$payInfo
[
"finish_num"
]
.
"单用户下单奖励"
;
}
$tmp
=
[];
$tmp
[
"op"
]
=
200
;
//200:团长奖励
$tmp
[
"op"
]
=
self
::
CAPITAL_POOL_OP
;
$tmp
[
"user_id"
]
=
$payInfo
[
"colonel_user_id"
];
$tmp
[
"amount"
]
=
$payInfo
[
"reward"
];
$tmp
[
"third_order_id"
]
=
$payInfo
[
"colonel_distributor_pay_info_id"
];
$tmp
[
"third_order_id_type"
]
=
$payInfo
[
"type"
];
$tmp
[
"third_order_desc"
]
=
$desc
;
$tmp
[
"third_order_desc"
]
=
self
::
getThirdOrderDesc
(
$payInfo
)
;
$data
[
"body"
][]
=
$tmp
;
}
$res
=
HttpUtil
::
post
(
$url
,
$data
,
100000
,
3
);
if
(
$res
[
'code'
]
==
0
&&
isset
(
$res
[
'response'
][
"result"
]))
{
$date
=
date
(
"Y-m-d H:i:s"
);
FileLog
::
info
(
"colonel_distributor_deducting_inventory"
,
$date
.
" 资金池授予用户奖励成功"
);
$this
->
loggerInfo
(
'资金池授予用户奖励成功,count='
.
count
(
$payInfoList
));
return
true
;
}
else
{
$msg
=
json_encode
([
"list"
=>
$data
]);
FileLog
::
error
(
"colonel_distributor_deducting_inventory"
,
$msg
,
null
,
'bp-server@yidian-inc.com'
);
$this
->
loggerError
(
"资金池授予用户奖励成功,
$msg
"
);
return
false
;
}
}
private
function
getPayInfoList
()
:
array
{
return
ColonelDistributorPayInfo
::
getRecords
([
'status'
=>
ColonelDistributorPayInfo
::
STATUS_NOT_USE
]);
}
/**
* Notes: 获取描述信息
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 6:10 下午
* @param $payInfo
* @return string
*/
private
function
getThirdOrderDesc
(
$payInfo
)
:
string
{
$desc
=
''
;
if
(
$payInfo
[
"type"
]
==
ColonelDistributorPayInfo
::
TYPE_NEW_USER
)
{
$desc
=
"邀请新用户("
.
$payInfo
[
"invite_user_nick"
]
.
")完成下单奖励"
;
}
elseif
(
$payInfo
[
"type"
]
==
ColonelDistributorPayInfo
::
TYPE_FINISH_TARGET
)
{
$desc
=
"完成"
.
$payInfo
[
"finish_num"
]
.
"单用户下单奖励"
;
}
return
$desc
;
}
/**
* 修改状态
* Notes: 修改状态
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 6:09 下午
* @param array $payInfoIds
* @return bool
*/
p
ublic
function
handlePayInfoStatus
(
array
$payInfoIds
)
p
rivate
function
handlePayInfoStatus
(
array
$payInfoIds
)
:
bool
{
return
ColonelDistributorPayInfo
::
updateRecord
([
'status'
=>
ColonelDistributorPayInfo
::
STATUS_USE
],
[
'pay_info_id'
=>
$payInfoIds
]);
}
}
\ No newline at end of file
/**
* Notes: 记录 info 日志
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:10 下午
* @param $log
*/
private
function
loggerInfo
(
$log
)
{
FileLog
::
error
(
"colonel_distributor_wallet"
,
'colonel_distributor_wallet:'
.
$log
,
false
,
true
);
}
/**
* Notes: 记录 error 日志
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 4:10 下午
* @param $log
*/
private
function
loggerError
(
$log
)
{
FileLog
::
error
(
"colonel_distributor_deducting_inventory"
,
$log
,
null
,
'bp-server@yidian-inc.com'
,
true
);
}
}
application/services/marketing/PindanActivityColonelConfigService.php
View file @
4f15265b
...
...
@@ -152,7 +152,30 @@ class PindanActivityColonelConfigService
$startTime
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
))
.
$hour
;
$endTime
=
date
(
"Y-m-d"
)
.
$hour
;
}
return
[
'start_time'
=>
$startTime
,
'end_time'
=>
$endTime
];
return
[
'start_time'
=>
$startTime
,
'end_time'
=>
$endTime
,
'date'
=>
date
(
'Y-m-d'
,
strtotime
(
$startTime
))
];
}
/**
* Notes: 获取结算时间范围
* User: pengfei@yidian-inc.com
* Date: 2021/9/3 2:50 下午
* @return string[]
*/
public
static
function
getSettlementTimeRange
()
:
array
{
// 获取活动时间范围 例如当前时间(2021-09-03 12:00:00) 应结算时间为 2021-09-01:12:00:00 - 2021-09-02:12:00:00
$hour
=
' '
.
self
::
ACTIVITY_DEFAULT_HOUR
.
":00:00"
;
$startTime
=
date
(
"Y-m-d"
,
strtotime
(
"-3 day"
))
.
$hour
;
$endTime
=
date
(
"Y-m-d"
,
strtotime
(
"-2 day"
))
.
$hour
;
return
[
'start_time'
=>
$startTime
,
'end_time'
=>
$endTime
,
'date'
=>
date
(
'Y-m-d'
,
strtotime
(
$startTime
))
];
}
}
\ No newline at end of file
vendor/api/php_utils/src/Log/FileLog.php
View file @
4f15265b
...
...
@@ -15,14 +15,18 @@ class FileLog
* @param string $signature 本条日志签名
* @param string $detail_info 日志详细信息
* @param bool $with_access_log
* @param bool $is_output 是否输出
*/
public
static
function
info
(
$signature
,
$detail_info
=
''
,
$with_access_log
=
false
)
public
static
function
info
(
$signature
,
$detail_info
=
''
,
$with_access_log
=
false
,
$is_output
=
false
)
{
$traceId
=
Tracer
::
getTraceId
();
$log
=
'PHP User_info: ['
.
$signature
.
'] [traceId:'
.
$traceId
.
'] [detail info:] '
.
$detail_info
;
if
(
$with_access_log
)
{
$log
.=
' [request info:] '
.
self
::
accessLog
();
}
if
(
$is_output
)
{
echo
$log
.
PHP_EOL
;
}
error_log
(
$log
);
}
...
...
@@ -32,8 +36,9 @@ class FileLog
* @param string $signature 本条日志签名
* @param string $detail_info 日志详细信息
* @param \Exception $exception 异常信息
* @param bool $is_output 是否输出
*/
public
static
function
waring
(
$signature
,
$detail_info
=
''
,
$exception
=
null
)
public
static
function
waring
(
$signature
,
$detail_info
=
''
,
$exception
=
null
,
$is_output
=
false
)
{
$traceId
=
Tracer
::
getTraceId
();
$log
=
'PHP User_warning: ['
.
$signature
.
'] [traceId:'
.
$traceId
.
'] [detail info:] '
.
$detail_info
.
' [request info:] '
.
self
::
accessLog
();
...
...
@@ -41,6 +46,9 @@ class FileLog
$exception_info
=
'In '
.
$exception
->
getFile
()
.
' on line '
.
$exception
->
getLine
()
.
' '
.
$exception
->
getCode
()
.
': '
.
$exception
->
getMessage
();
$log
.=
' [exception info: ]'
.
$exception_info
;
}
if
(
$is_output
)
{
echo
$log
.
PHP_EOL
;
}
error_log
(
$log
);
}
...
...
@@ -51,8 +59,9 @@ class FileLog
* @param string $detail_info 日志详细信息
* @param \Exception $exception 异常信息
* @param array|string $mail_to 邮件接受者
* @param bool $is_output 是否输出
*/
public
static
function
error
(
$signature
,
$detail_info
=
''
,
$exception
=
null
,
$mail_to
=
''
)
public
static
function
error
(
$signature
,
$detail_info
=
''
,
$exception
=
null
,
$mail_to
=
''
,
$is_output
=
false
)
{
$traceId
=
Tracer
::
getTraceId
();
$log
=
'PHP User_error: ['
.
$signature
.
'] [traceId:'
.
$traceId
.
'] [detail info:] '
.
$detail_info
.
' [request info:] '
.
self
::
accessLog
();
...
...
@@ -81,6 +90,9 @@ class FileLog
Email
::
sendMail
(
'bp-noreply@yidian-inc.com'
,
$mail
,
$subject
,
$body
);
}
}
if
(
$is_output
)
{
echo
$log
.
PHP_EOL
;
}
}
public
static
function
accessLog
()
...
...
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