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
a51ec45c
...
a51ec45cd5bd15485d7752c386682c5b68b28f17
authored
2021-09-15 10:00:28 +0800
by
lemon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
数据同步
1 parent
0edb8808
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
8 deletions
app/Jobs/StakeholderIncomeSyncJob.php
config/logging.php
app/Jobs/StakeholderIncomeSyncJob.php
View file @
a51ec45
...
...
@@ -6,6 +6,7 @@ use App\Helper\CacheKeyTools;
use
App\Helper\RedisClient
;
use
App\Models\Legal\Bills
;
use
App\Models\Legal\Company
;
use
App\Models\Legal\StakeholderIncomeByPayer
;
use
App\Services\ApiService
;
use
App\Traits\TaxReckon
;
use
Illuminate\Bus\Queueable
;
...
...
@@ -16,6 +17,10 @@ use Illuminate\Queue\InteractsWithQueue;
use
Illuminate\Queue\SerializesModels
;
use
Illuminate\Support\Facades\Log
;
/**
* Class StakeholderIncomeSyncJob
* @package App\Jobs
*/
class
StakeholderIncomeSyncJob
implements
ShouldQueue
{
use
Dispatchable
,
InteractsWithQueue
,
Queueable
,
SerializesModels
,
TaxReckon
;
...
...
@@ -51,7 +56,7 @@ class StakeholderIncomeSyncJob implements ShouldQueue
$key
=
CacheKeyTools
::
billsSync
();
//处理消息体
if
(
$msg
=
$redis
->
xread
([
$key
=>
$id
],
1
,
3
))
{
if
(
$msg
=
$redis
->
xread
([
$key
=>
$id
],
self
::
COUNT
,
self
::
BLOCK_TIME
))
{
$id
=
key
(
$msg
[
$key
]);
$income_item
=
$msg
[
$key
][
$id
];
...
...
@@ -59,9 +64,8 @@ class StakeholderIncomeSyncJob implements ShouldQueue
$company
=
Company
::
query
()
->
find
(
$income_item
[
'company_id'
]);
$bills
=
Bills
::
query
()
->
find
(
$income_item
[
'related_id'
]);
$channel
=
'TME'
;
$title
=
"
{
$bills
->
bill_section_start
}
-
{
$bills
->
bill_section_end
}
账单/
{
$channel
}
"
;
$http_
res
=
ApiService
::
walletAddIncome
(
[
$http_
data
=
[
'cardNo'
=>
$income_item
[
'identifier'
],
'faxMoney'
=>
$income_item
[
'fax_money'
],
'money'
=>
$income_item
[
'money'
],
...
...
@@ -69,18 +73,31 @@ class StakeholderIncomeSyncJob implements ShouldQueue
'paymentCompany'
=>
$company
->
receipt_name
,
'type'
=>
self
::
TYPE_BILLS
,
'title'
=>
"
{
$bills
->
bill_section_start
}
-
{
$bills
->
bill_section_end
}
账单/
{
$channel
}
"
,
]);
];
$http_res
=
ApiService
::
walletAddIncome
(
$http_data
);
if
(
empty
(
$http_res
))
{
//重试 401/403/403
Log
::
info
(
__METHOD__
.
'请求失败'
);
Log
::
channel
(
'api'
)
->
warning
(
__METHOD__
.
"streamid:
{
$id
}
-api请求失败"
,
[
'income_item'
=>
$income_item
,
'http_data'
=>
$http_data
]
);
}
else
{
switch
(
$http_res
[
'code'
])
{
}
}
$update
=
[
'http_log'
=>
json_encode
(
$http_res
,
JSON_UNESCAPED_UNICODE
),
'busi_id'
=>
$http_res
[
'data'
][
'busiId'
],
];
if
(
$http_res
[
'code'
]
==
0
)
{
$update
[
'sync_status'
]
=
1
;
}
else
{
$update
[
'sync_status'
]
=
2
;
}
//记录请求api返回体并修改状态
if
(
StakeholderIncomeByPayer
::
query
()
->
where
([
'serial_no'
=>
$income_item
[
'serial_no'
]])
->
update
(
$update
))
{
$redis
->
xdel
(
$key
,
[
$id
]);
}
}
}
}
...
...
config/logging.php
View file @
a51ec45
...
...
@@ -108,6 +108,12 @@ return [
'level'
=>
env
(
'LOG_LEVEL'
,
'debug'
),
'days'
=>
14
,
],
'api'
=>
[
'driver'
=>
'daily'
,
'path'
=>
storage_path
(
'logs/laravel-api.log'
),
'level'
=>
env
(
'LOG_LEVEL'
,
'debug'
),
]
],
];
...
...
Please
register
or
sign in
to post a comment