Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
openApi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hj
openApi
Commits
a15f87be
Commit
a15f87be
authored
Sep 15, 2022
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
震坤行
parent
05dd32f9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
123 additions
and
6 deletions
+123
-6
server/app/Console/Commands/ZhenkhJobCommand.php
server/app/Console/Commands/ZhenkhJobCommand.php
+36
-2
server/app/Jobs/queue/ZhenkhQueueJob.php
server/app/Jobs/queue/ZhenkhQueueJob.php
+35
-0
server/app/Services/ZhenKhService.php
server/app/Services/ZhenKhService.php
+15
-3
server/bootstrap/app.php
server/bootstrap/app.php
+1
-1
server/database/migrations/2022_09_15_133802_create_consumer_queue_jobs_table.php
...ns/2022_09_15_133802_create_consumer_queue_jobs_table.php
+36
-0
No files found.
server/app/Console/Commands/ZhenkhJobCommand.php
View file @
a15f87be
...
...
@@ -3,6 +3,7 @@ namespace App\Console\Commands;
use
App\Jobs\WuxiLabJob
;
use
App\Jobs\ZhenkhJob
;
use
App\Services\ZhenKhService
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\ConfirmableTrait
;
...
...
@@ -57,8 +58,41 @@ class ZhenkhJobCommand extends Command
exit
;
}
$productUpdateJob
=
(
new
ZhenkhJob
(
$action_type
,
$params
))
->
delay
(
100
)
->
onQueue
(
'slow'
);
app
(
'Illuminate\Contracts\Bus\Dispatcher'
)
->
dispatch
(
$productUpdateJob
);
$service
=
app
(
ZhenKhService
::
class
);
switch
(
$action_type
){
case
'test'
:
$service
->
test
();
break
;
case
'getUpdateGoods'
:
$service
->
getUpdateSupplierGoods
();
break
;
case
'getUpdateOrders'
:
$service
->
getUpdateSupplierOrders
();
break
;
case
'sendDeliveryOrder'
:
$service
->
sendDeliveryOrder
(
$params
);
break
;
case
'getDeliveryOrderDetail'
:
$service
->
getDeliveryOrderPdf
(
$params
);
break
;
case
'orderNoRollBack'
:
$service
->
orderNoRollBack
();
break
;
case
'createJwtToken'
:
$service
->
createJwtToken
();
break
;
case
'hMUpdateOrdersList'
:
$service
->
hMUpdateOrdersList
();
break
;
case
'sendMail'
:
$service
->
sendMail
(
'订单确认邮件'
,
'订单号:未确认成功'
);
case
'orderConfirm'
:
$service
->
orderConfirm
(
$params
);
default
:
}
/*$productUpdateJob = (new ZhenkhJob($action_type,$params))->delay(100);
app('Illuminate\Contracts\Bus\Dispatcher')->dispatch($productUpdateJob);*/
}
}
...
...
server/app/Jobs/queue/ZhenkhQueueJob.php
0 → 100644
View file @
a15f87be
<?php
namespace
App\Jobs\queue
;
use
App\Jobs\Job
;
class
ZhenkhQueueJob
extends
Job
{
public
$params
;
/**
* Create a new job instance.
*
* @return void
*/
public
function
__construct
(
$params
=
''
)
{
$this
->
params
=
$params
;
}
/**
* Execute the job.
*
* @return void
*/
public
function
handle
()
{
if
(
!
empty
(
$this
->
params
)){
if
(
isset
(
$this
->
params
[
'method'
])
&&
method_exists
(
$this
->
params
[
'consumer'
],
$this
->
params
[
'method'
])){
//app($this->params['consumer'])->$this->params['method']($this->params['params']);
$method
=
$this
->
params
[
'method'
];
call_user_func
([
app
(
$this
->
params
[
'consumer'
]),
$method
],
$this
->
params
[
'params'
]);
//app($this->params['consumer'])->{$method}($this->params['params']);
}
}
}
}
\ No newline at end of file
server/app/Services/ZhenKhService.php
View file @
a15f87be
...
...
@@ -2,6 +2,7 @@
namespace
App\Services
;
use
App\Jobs\queue\ZhenkhQueueJob
;
use
App\Mailer\MailService
;
use
App\Mailer\MailTempl
;
use
App\Repositories\Contracts\ThirdApiPlatformRepository
;
...
...
@@ -126,7 +127,7 @@ class ZhenKhService
'consumer'
=>
__CLASS__
,
'method'
=>
'consumerBatchUpdateGoodsList'
];
SimpleKafka
::
produerSend
(
$sendContent
,
'zkh'
);
$this
->
pushQueue
(
$sendContent
);
}
}
...
...
@@ -175,11 +176,11 @@ class ZhenKhService
if
(
$orderList
&&
count
(
$orderList
[
'list'
])
>
0
){
foreach
(
$orderList
[
'list'
][
'data'
]
as
$order
){
if
(
$order
[
'orderStatus'
]
==
0
){
SimpleKafka
::
produerSend
([
$this
->
pushQueue
([
'params'
=>
[
'orders'
=>
$order
],
'consumer'
=>
__CLASS__
,
'method'
=>
'consumerBatchUpdateOrdersList'
]
,
'zkh'
);
]);
}
}
}
...
...
@@ -545,4 +546,15 @@ class ZhenKhService
}
}
private
function
pushQueue
(
$pushContent
)
{
if
(
env
(
'QUEUE_CONNECTION'
)
==
'database'
){
app
(
'Illuminate\Contracts\Bus\Dispatcher'
)
->
dispatch
(
(
new
ZhenkhQueueJob
(
$pushContent
))
->
onQueue
(
'zkh'
)
);
}
else
{
SimpleKafka
::
produerSend
(
$pushContent
,
'zkh'
);
}
}
}
server/bootstrap/app.php
View file @
a15f87be
...
...
@@ -140,7 +140,7 @@ $app->register(Dingo\Api\Provider\LumenServiceProvider::class);
$app
->
register
(
\Jiannei\Enum\Laravel\Providers\LumenServiceProvider
::
class
);
$app
->
register
(
\Jiannei\Response\Laravel\Providers\LumenServiceProvider
::
class
);
$app
->
register
(
\Jiannei\Logger\Laravel\Providers\ServiceProvider
::
class
);
//
$app->register(\Jiannei\Logger\Laravel\Providers\ServiceProvider::class);
$app
->
register
(
Maatwebsite\Excel\ExcelServiceProvider
::
class
);
$app
->
register
(
Spatie\CronlessSchedule\CronlessScheduleServiceProvider
::
class
);
...
...
server/database/migrations/2022_09_15_133802_create_consumer_queue_jobs_table.php
0 → 100644
View file @
a15f87be
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
class
CreateConsumerQueueJobsTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'consumer_queue_jobs'
,
function
(
Blueprint
$table
)
{
$table
->
bigIncrements
(
'id'
);
$table
->
string
(
'queue'
)
->
index
();
$table
->
longText
(
'payload'
);
$table
->
unsignedTinyInteger
(
'attempts'
);
$table
->
unsignedInteger
(
'reserved_at'
)
->
nullable
();
$table
->
unsignedInteger
(
'available_at'
);
$table
->
unsignedInteger
(
'created_at'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'consumer_queue_jobs'
);
}
}
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