Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Cong.Zhao
/
musician-api.hikoon.com
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
0a0bbb6f
...
0a0bbb6fb6f0fef265da156622f803f862c62bc1
authored
2021-11-15 10:53:18 +0800
by
lemon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
同步分贝
1 parent
8db02e59
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
8 deletions
app/Console/Commands/StakeholderIncomeSyncCommand.php
app/Models/Legal/StakeholderIncomeSyncAppLogs.php
app/Console/Commands/StakeholderIncomeSyncCommand.php
View file @
0a0bbb6
...
...
@@ -3,13 +3,17 @@
namespace
App\Console\Commands
;
use
App\Helper\CacheKeyTools
;
use
App\Helper\ErrorCode
;
use
App\Helper\RedisClient
;
use
App\Helper\Response
;
use
App\Models\Legal\Bills
;
use
App\Models\Legal\Company
;
use
App\Models\Legal\StakeholderIncomeSyncApp
;
use
App\Models\Legal\StakeholderIncomeSyncAppDetails
;
use
App\Models\Legal\StakeholderIncomeSyncAppLogs
;
use
App\Services\ApiService
;
use
Illuminate\Console\Command
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\Log
;
/**
...
...
@@ -40,7 +44,6 @@ class StakeholderIncomeSyncCommand extends Command
const
BLOCK_TIME
=
1000
;
const
TYPE_BILLS
=
"1001601"
;
//账单分成
const
TYPE_ROYALTY
=
"1001602"
;
//合作伙伴打款 type = 1 版税分成
/**
* Create a new command instance.
...
...
@@ -79,21 +82,52 @@ class StakeholderIncomeSyncCommand extends Command
//http
$http_res
=
ApiService
::
walletAddIncome
(
$http_data
);
if
(
empty
(
$http_res
))
{
//重试 401/403/403
Log
::
channel
(
'api'
)
->
warning
(
__METHOD__
.
"streamid:
{
$id
}
-api请求失败"
,
[
'income_item'
=>
$income_item
,
'http_data'
=>
$http_data
]);
}
else
{
//成功
Log
::
channel
(
'api'
)
->
info
(
__METHOD__
.
"同步反馈"
,
[
'stream-id'
=>
$id
,
'serial_no'
=>
$serial_no
,
'request'
=>
$http_data
,
'response'
=>
$http_res
]);
}
//处理返回体
$this
->
dealResponse
(
$serial_no
,
$http_data
,
$http_res
);
}
else
{
Log
::
channel
(
'api'
)
->
info
(
__METHOD__
,
[
'msg'
=>
'找不到需要同步的对应的收益记录'
,
'serial_no'
=>
$serial_no
]);
}
$this
->
consumeTask
(
$redis
,
$key
,
$id
);
}
}
}
/**
* 处理返回体
* @param $serial_no
* @param $http_res
*/
private
function
dealResponse
(
$serial_no
,
$request
,
$response
)
{
DB
::
beginTransaction
();
try
{
StakeholderIncomeSyncAppLogs
::
query
()
->
create
([
'serial_no'
=>
$serial_no
,
'request_log'
=>
$request
,
'response_log'
=>
$response
]);
if
(
!
empty
(
$response
)
&&
(
$response
[
'code'
]
==
0
))
{
StakeholderIncomeSyncApp
::
query
()
->
where
([
'serial_no'
=>
$serial_no
])
->
update
([
'busi_id'
=>
$response
[
'id'
],
'sync_status'
=>
1
,
]);
}
DB
::
commit
();
}
catch
(
\Exception
$e
)
{
DB
::
rollBack
();
Log
::
channel
(
'api'
)
->
error
(
__METHOD__
,
[
'msg'
=>
$e
->
getMessage
(),
'request'
=>
$request
,
'response'
=>
$response
]);
}
}
/**
...
...
@@ -153,7 +187,7 @@ class StakeholderIncomeSyncCommand extends Command
foreach
(
$income_detail
as
$item
)
{
$body
[
'addLevelTwoIncomeRequests'
][]
=
[
'actualTime'
=>
(
string
)
$item
->
created_at
,
'actualTime'
=>
$item
->
created_at
,
'busiId'
=>
$item
->
serial_no
,
'faxMoney'
=>
$item
->
fax_money
,
'money'
=>
$item
->
money
,
...
...
app/Models/Legal/StakeholderIncomeSyncAppLogs.php
0 → 100644
View file @
0a0bbb6
<?php
namespace
App\Models\Legal
;
use
App\Models\BaseModel
;
use
Illuminate\Support\Facades\DB
;
/**
* Class stakeholderIncomeSyncApp
* @package App\Models
*/
class
StakeholderIncomeSyncAppLogs
extends
BaseModel
{
/**
* @var string
*/
protected
$table
=
'stakeholder_income_sync_app_logs'
;
/**
* @var array
*/
protected
$guarded
=
[];
protected
$casts
=
[
'request_log'
=>
'json'
,
'response_log'
=>
'json'
,
];
}
Please
register
or
sign in
to post a comment