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
126a3371
Commit
126a3371
authored
Aug 31, 2021
by
pengfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update 团长分销-奖励脚本
parent
eef5cfcb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
220 deletions
+40
-220
Colonelorder.php
application/modules/Cli/controllers/Colonelorder.php
+24
-102
Colonelwallet.php
application/modules/Cli/controllers/Colonelwallet.php
+15
-16
Colonelwallet.php
daemon/Colonelwallet.php
+1
-102
No files found.
application/modules/Cli/controllers/Colonelorder.php
View file @
126a3371
...
@@ -3,14 +3,13 @@
...
@@ -3,14 +3,13 @@
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpUtils\Log\FileLog
;
use
Api\PhpUtils\Log\FileLog
;
use
App\Base\Cli
;
use
App\Base\Cli
;
use
\App\Models\marketing\mysql\ColonelDistributorColonel
;
use
App\Models\marketing\mysql\ColonelDistributorColonel
;
use
\App\Models\marketing\mysql\ColonelDistributorInviteOrder
;
use
App\Models\marketing\mysql\ColonelDistributorConfig
;
use
\App\Models\marketing\mysql\ColonelDistributorConfig
;
use
App\Models\marketing\mysql\ColonelDistributorInviteOrderNum
;
use
\App\Models\marketing\mysql\ColonelDistributorInviteOrderNum
;
use
App\Models\marketing\mysql\ColonelDistributorPayInfo
;
use
\App\Models\marketing\mysql\ColonelDistributorPayInfo
;
use
App\Exception\custom\InterfaceException
;
use
\App\Exception\custom\InterfaceException
;
use
Api\PhpUtils\Http\HttpUtil
;
use
Api\PhpUtils\Http\HttpUtil
;
use
\
App\Models\user\mysql\UserWechatBind
;
use
App\Models\user\mysql\UserWechatBind
;
/**
/**
* php public/cli.php colonelorder index
* php public/cli.php colonelorder index
...
@@ -35,84 +34,6 @@ class ColonelorderController extends Cli
...
@@ -35,84 +34,6 @@ class ColonelorderController extends Cli
}
}
}
}
public
function
indexBakAction
()
{
$userIdList
=
$this
->
getColonelUserIds
();
ColonelDistributorPayInfo
::
beginTransaction
();
if
(
!
empty
(
$userIdList
))
{
$userIdCount
=
count
(
$userIdList
);
//每次100个用户
$length
=
1
;
$start
=
(
int
)
ceil
(
$userIdCount
/
$length
);
$insertData
=
[];
for
(
$i
=
0
;
$i
<
$start
;)
{
$userIds
=
array_slice
(
$userIdList
,
$i
,
$length
);
$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
);
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
);
if
(
!
empty
(
$inviteNewUserList
))
{
$colonelUserIds
=
array_column
(
$inviteNewUserList
,
"user_id"
);
$userNickList
=
$this
->
getUserList
(
$colonelUserIds
);
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
;
}
}
}
$i
=
$i
+
$length
;
}
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
();
}
}
public
function
indexAction
()
public
function
indexAction
()
{
{
$userIdList
=
$this
->
getColonelUserIds
();
$userIdList
=
$this
->
getColonelUserIds
();
...
@@ -127,8 +48,18 @@ class ColonelorderController extends Cli
...
@@ -127,8 +48,18 @@ class ColonelorderController extends Cli
$batchPayInfoData
[]
=
$this
->
getInviteOrderData
(
$userIds
);
$batchPayInfoData
[]
=
$this
->
getInviteOrderData
(
$userIds
);
// 邀请新用户奖励
// 邀请新用户奖励
$batchPayInfoData
[]
=
$this
->
getInviteNewUserData
(
$userIds
);
$batchPayInfoData
[]
=
$this
->
getInviteNewUserData
(
$userIds
);
$colonelPayInfoData
=
array_merge
(
$colonelPayInfoData
,
$batchPayInfoData
);
$colonelPayInfoData
=
array_merge
(
$colonelPayInfoData
,
$batchPayInfoData
);
}
}
return
$this
->
handleSavePayInfo
(
$colonelPayInfoData
);
}
/**
* 保存奖励信息
* @param $yesterday
* @return true
*/
public
function
handleSavePayInfo
(
$colonelPayInfoData
)
{
if
(
!
empty
(
$colonelPayInfoData
))
{
if
(
!
empty
(
$colonelPayInfoData
))
{
$data
=
$this
->
addIdgenId
(
$colonelPayInfoData
);
$data
=
$this
->
addIdgenId
(
$colonelPayInfoData
);
try
{
try
{
...
@@ -141,7 +72,7 @@ class ColonelorderController extends Cli
...
@@ -141,7 +72,7 @@ class ColonelorderController extends Cli
}
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
ColonelDistributorPayInfo
::
rollback
();
ColonelDistributorPayInfo
::
rollback
();
FileLog
::
info
(
"add_colonel_distributor_pay_info"
,
$e
->
getMessage
());
FileLog
::
info
(
"add_colonel_distributor_pay_info"
,
$e
->
getMessage
());
}
}
}
}
return
true
;
return
true
;
...
@@ -236,17 +167,6 @@ class ColonelorderController extends Cli
...
@@ -236,17 +167,6 @@ class ColonelorderController extends Cli
return
$userIds
;
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
* 获取order num
* @param $colonelUserIds
* @param $colonelUserIds
...
@@ -256,12 +176,15 @@ class ColonelorderController extends Cli
...
@@ -256,12 +176,15 @@ class ColonelorderController extends Cli
*/
*/
public
function
getInviteOrderNum
(
$colonelUserIds
,
$startTime
,
$endTime
)
public
function
getInviteOrderNum
(
$colonelUserIds
,
$startTime
,
$endTime
)
{
{
return
ColonelDistributorInviteOrderNum
::
select
([
"colonel_user_id"
,
"num"
,
"date"
],
return
ColonelDistributorInviteOrderNum
::
select
(
[
"colonel_user_id"
,
"num"
,
"date"
],
[
[
"colonel_user_id"
=>
$colonelUserIds
,
"colonel_user_id"
=>
$colonelUserIds
,
"date[>=]"
=>
$startTime
,
"date[>=]"
=>
$startTime
,
"date[<=]"
=>
$endTime
,
"date[<=]"
=>
$endTime
,
],
[]);
],
[]
);
}
}
/**
/**
...
@@ -329,5 +252,4 @@ class ColonelorderController extends Cli
...
@@ -329,5 +252,4 @@ class ColonelorderController extends Cli
{
{
return
ColonelDistributorPayInfo
::
save
(
$data
);
return
ColonelDistributorPayInfo
::
save
(
$data
);
}
}
}
}
\ No newline at end of file
application/modules/Cli/controllers/Colonelwallet.php
View file @
126a3371
<?php
<?php
use
Api\PhpServices\Idgen\Idgen
;
use
Api\PhpUtils\Log\FileLog
;
use
Api\PhpUtils\Log\FileLog
;
use
App\Base\Cli
;
use
App\Base\Cli
;
use
\App\Models\marketing\mysql\ColonelDistributorColonel
;
use
App\Models\marketing\mysql\ColonelDistributorPayInfo
;
use
\App\Models\marketing\mysql\ColonelDistributorInviteOrder
;
use
App\Exception\custom\InterfaceException
;
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
Api\PhpUtils\Http\HttpUtil
;
use
\App\Models\user\mysql\UserWechatBind
;
/**
/**
* php public/cli.php colonelwallet index
* php public/cli.php colonelwallet index
...
@@ -19,19 +13,15 @@ class ColonelwalletController extends Cli
...
@@ -19,19 +13,15 @@ class ColonelwalletController extends Cli
{
{
public
function
indexAction
()
public
function
indexAction
()
{
{
// $today = date("Y-m-d");
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$payInfoList
=
$this
->
getPayInfo
(
$yesterday
);
$payInfoList
=
$this
->
getPayInfo
(
$yesterday
);
if
(
!
empty
(
$payInfoList
))
{
if
(
!
empty
(
$payInfoList
))
{
if
(
$this
->
toWallet
(
$payInfoList
))
{
if
(
$this
->
toWallet
(
$payInfoList
))
{
if
(
$this
->
deductingInventory
(
$payInfoList
))
{
if
(
$this
->
deductingInventory
(
$payInfoList
))
{
$this
->
handlePayInfoStatus
(
array_column
(
$payInfoList
,
'colonel_distributor_pay_info_id'
));
$this
->
handlePayInfoStatus
(
array_column
(
$payInfoList
,
'colonel_distributor_pay_info_id'
));
}
}
}
}
}
}
}
}
/**
/**
...
@@ -107,13 +97,22 @@ class ColonelwalletController extends Cli
...
@@ -107,13 +97,22 @@ class ColonelwalletController extends Cli
$data
[
"capital_pool_id"
]
=
2
;
$data
[
"capital_pool_id"
]
=
2
;
foreach
(
$payInfoList
as
$payInfo
)
{
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
=
[];
$tmp
[
"op"
]
=
200
;
//200:团长奖励
$tmp
[
"op"
]
=
200
;
//200:团长奖励
$tmp
[
"user_id"
]
=
$payInfo
[
"colonel_user_id"
];
$tmp
[
"user_id"
]
=
$payInfo
[
"colonel_user_id"
];
$tmp
[
"amount"
]
=
$payInfo
[
"reward"
];
$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
;
$data
[
"body"
][]
=
$tmp
;
$data
[
"body"
][]
=
$tmp
;
}
}
$res
=
HttpUtil
::
post
(
$url
,
$data
,
100000
,
3
);
$res
=
HttpUtil
::
post
(
$url
,
$data
,
100000
,
3
);
if
(
$res
[
'code'
]
==
0
&&
isset
(
$res
[
'response'
][
"result"
]))
{
if
(
$res
[
'code'
]
==
0
&&
isset
(
$res
[
'response'
][
"result"
]))
{
$date
=
date
(
"Y-m-d H:i:s"
);
$date
=
date
(
"Y-m-d H:i:s"
);
FileLog
::
info
(
"colonel_distributor_deducting_inventory"
,
$date
.
" 资金池授予用户奖励成功"
);
FileLog
::
info
(
"colonel_distributor_deducting_inventory"
,
$date
.
" 资金池授予用户奖励成功"
);
...
@@ -130,6 +129,6 @@ class ColonelwalletController extends Cli
...
@@ -130,6 +129,6 @@ class ColonelwalletController extends Cli
*/
*/
public
function
handlePayInfoStatus
(
array
$payInfoIds
)
public
function
handlePayInfoStatus
(
array
$payInfoIds
)
{
{
return
ColonelDistributorPayInfo
::
updateRecord
([
'status'
=>
ColonelDistributorPayInfo
::
STATUS_USE
],[
'id'
=>
$payInfoIds
]);
return
ColonelDistributorPayInfo
::
updateRecord
([
'status'
=>
ColonelDistributorPayInfo
::
STATUS_USE
],
[
'id'
=>
$payInfoIds
]);
}
}
}
}
\ No newline at end of file
daemon/Colonelwallet.php
View file @
126a3371
...
@@ -19,107 +19,6 @@ class Colonelwallet implements DaemonServiceInterface
...
@@ -19,107 +19,6 @@ class Colonelwallet implements DaemonServiceInterface
sleep
(
5
);
sleep
(
5
);
return
false
;
return
false
;
}
}
\Yaf\Application
::
app
()
->
bootstrap
()
->
getDispatcher
()
->
dispatch
(
new
\Yaf\Request\Simple
(
''
,
'cli'
,
'colonelwallet'
,
'index'
,
[]));
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$payInfoList
=
$this
->
getPayInfo
(
$yesterday
);
if
(
!
empty
(
$payInfoList
))
{
$res
=
$this
->
toWallet
(
$payInfoList
);
if
(
$res
)
{
$this
->
deductingInventory
(
$payInfoList
);
}
}
}
/**
* colonel_distributor_pay_info 数据
* @param $date
* @return array
*/
public
function
getPayInfo
(
$date
)
{
$list
=
ColonelDistributorPayInfo
::
select
(
"*"
,
[
"date"
=>
$date
],
[]);
$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
))
{
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
[
"third_order_id"
]
=
$payInfo
[
"colonel_distributor_pay_info_id"
];
$tmp
[
"third_order_id_type"
]
=
$payInfo
[
"type"
];
$tmp
[
"third_order_desc"
]
=
$desc
;
$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
.
" 写入钱包成功"
);
return
true
;
}
else
{
$msg
=
json_encode
([
"list"
=>
$data
]);
FileLog
::
error
(
"colonel_distributor_to_wallet"
,
$msg
,
null
,
'bp-server@yidian-inc.com'
);
return
false
;
}
}
/**
* 资金池授予用户奖励
*/
public
function
deductingInventory
(
$payInfoList
)
{
$url
=
config
(
'interface'
,
'coupon.capitalpool.grant_user_amount'
);
if
(
empty
(
$url
))
{
throw
new
InterfaceException
([
'cus'
=>
0
]);
}
$data
[
"capital_pool_id"
]
=
2
;
foreach
(
$payInfoList
as
$payInfo
)
{
$tmp
=
[];
$tmp
[
"op"
]
=
200
;
//200:团长奖励
$tmp
[
"user_id"
]
=
$payInfo
[
"colonel_user_id"
];
$tmp
[
"amount"
]
=
$payInfo
[
"reward"
];
$data
[
"body"
][]
=
$tmp
;
}
$res
=
HttpUtil
::
post
(
$url
,
$data
);
if
(
$res
[
'code'
]
==
0
&&
isset
(
$res
[
'response'
][
"result"
]))
{
$date
=
date
(
"Y-m-d H:i:s"
);
FileLog
::
info
(
"colonel_distributor_deducting_inventory"
,
$date
.
" 资金池授予用户奖励成功"
);
return
true
;
}
else
{
$msg
=
json_encode
([
"list"
=>
$data
]);
FileLog
::
error
(
"colonel_distributor_deducting_inventory"
,
$msg
,
null
,
'bp-server@yidian-inc.com'
);
return
false
;
}
}
}
}
}
\ 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