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
43cf263b
Commit
43cf263b
authored
Aug 28, 2021
by
luhongguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 写入钱包
parent
620cc708
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
5 deletions
+86
-5
Colonelwallet.php
application/modules/Cli/controllers/Colonelwallet.php
+86
-5
No files found.
application/modules/Cli/controllers/Colonelwallet.php
View file @
43cf263b
...
...
@@ -19,27 +19,108 @@ class ColonelwalletController extends Cli
{
public
function
indexAction
()
{
// $today = date("Y-m-d");
$yesterday
=
date
(
"Y-m-d"
,
strtotime
(
"-1 day"
));
$payInfoList
=
$this
->
getPayInfo
(
$yesterday
);
if
(
!
empty
(
$payInfoList
))
{
$res
=
$this
->
toWallet
(
$payInfoList
);
if
(
$res
)
{
$this
->
deductingInventory
(
$payInfoList
);
}
}
public
function
getPayInfo
()
{
}
/**
* 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
()
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
()
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