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
e4d9fc08
Commit
e4d9fc08
authored
Jan 30, 2023
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
罗恩测试工具
parent
916693e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
157 additions
and
1 deletion
+157
-1
server/app/Console/Commands/RhawnToolsJobCommand.php
server/app/Console/Commands/RhawnToolsJobCommand.php
+81
-0
server/app/Providers/AppServiceProvider.php
server/app/Providers/AppServiceProvider.php
+2
-1
server/app/TestTools/Rhawn/RhawnToolsService.php
server/app/TestTools/Rhawn/RhawnToolsService.php
+74
-0
No files found.
server/app/Console/Commands/RhawnToolsJobCommand.php
0 → 100644
View file @
e4d9fc08
<?php
namespace
App\Console\Commands
;
use
App\Services\ThirdPlatform\ZhenKhService
;
use
App\TestTools\Rhawn\RhawnToolsService
;
use
Illuminate\Console\Command
;
use
Illuminate\Console\ConfirmableTrait
;
class
RhawnToolsJobCommand
extends
Command
{
use
ConfirmableTrait
;
/**
* 命令行的名称及用法。
*
* @var string
*/
protected
$signature
=
'tools:job
{--action_type= : 任务操作类型}
{--params= : 任务参数}'
;
/**
* 命令行的概述。
*
* @var string
*/
protected
$description
=
'罗恩任务命令行'
;
/**
* 创建新的命令实例。
*
* @return void
*/
public
function
__construct
()
{
parent
::
__construct
();
}
/**
* 运行命令。
* @throws \Exception
*/
public
function
handle
()
{
if
(
!
$this
->
confirmToProceed
())
{
return
1
;
}
if
(
$this
->
hasArgument
(
'help'
)){
$this
->
help
();
}
else
{
$action_type
=
$this
->
option
(
'action_type'
);
$params
=
$this
->
option
(
'params'
);
if
(
empty
(
$action_type
)){
$this
->
error
(
'缺少命令参数,请输入具体的参数命令.如需帮助请输入 --help'
);
exit
;
}
list
(
$cusCode
,
$discount
)
=
explode
(
','
,
$params
);
$service
=
app
(
RhawnToolsService
::
class
);
switch
(
$action_type
){
case
'updateCustomerOrdersPricesByDiscount'
:
$service
->
updateCustomerOrdersPricesByDiscount
(
$cusCode
,
$discount
);
break
;
default
:
}
/*$productUpdateJob = (new ZhenkhJob($action_type,$params))->delay(100);
app('Illuminate\Contracts\Bus\Dispatcher')->dispatch($productUpdateJob);*/
}
}
public
function
help
()
{
$helpStr
=
"参数帮助说明"
;
$this
->
comment
(
$this
->
setHelp
(
$helpStr
)
->
getProcessedHelp
());
$this
->
line
(
"action_type: 具体动作参数
\n\n
initProductToExcel => 初始化批量商品
\n
batchUpdateProduct => 批量更新商品
\n\n
params : 操作需要传入的参数.非必填项"
);
}
}
server/app/Providers/AppServiceProvider.php
View file @
e4d9fc08
...
...
@@ -76,7 +76,8 @@ class AppServiceProvider extends ServiceProvider
\App\Console\Commands\LeyanJobCommand
::
class
,
\App\Console\Commands\ThirdPlatformJobCommand
::
class
,
\App\Console\Commands\KafkaConsumerCommand
::
class
,
\App\Console\Commands\TestJobCommand
::
class
\App\Console\Commands\TestJobCommand
::
class
,
\App\Console\Commands\RhawnToolsJobCommand
::
class
]);
}
...
...
server/app/TestTools/Rhawn/RhawnToolsService.php
0 → 100644
View file @
e4d9fc08
<?php
namespace
App\TestTools\Rhawn
;
use
App\Rhawn\Repositories\Eloquent\RhawnSordersRepositoryEloquent
;
use
App\Rhawn\Services\RhawnCustomerService
;
use
App\Support\Facades\SimpleLogs
;
use
Illuminate\Support\Facades\DB
;
class
RhawnToolsService
{
public
function
__construct
(
\App\Rhawn\Services\RhawnOrdersService
$rhawnOrdersService
)
{
$this
->
rhawnOrdersService
=
$rhawnOrdersService
;
$this
->
rhawnCustomerService
=
app
(
RhawnCustomerService
::
class
);
}
/**
* 修改用户订单价格
*/
public
function
updateCustomerOrdersPricesByDiscount
(
$cusCode
,
$discount
)
{
$customer
=
$this
->
rhawnCustomerService
->
checkCustomerExist
(
$cusCode
);
if
(
$customer
){
$rhawnOrderRepository
=
app
(
RhawnSordersRepositoryEloquent
::
class
);
$orderList
=
$rhawnOrderRepository
->
getOrdersListThroughtUserId
(
$customer
[
'cus_id'
],
1
,
1000
);
if
(
$orderList
)
{
$armedOrders
=
[];
foreach
(
$orderList
as
$order
)
{
if
(
$order
[
'so_review_status'
]
==
0
)
{
array_push
(
$armedOrders
,
$order
);
}
}
$connection
=
DB
::
connection
(
$rhawnOrderRepository
->
getConnectionName
());
try
{
$connection
->
beginTransaction
();
//处理状态0的订单
if
(
count
(
$armedOrders
)
>
0
)
{
foreach
(
$armedOrders
as
$order
)
{
$orderDetail
=
$this
->
rhawnOrdersService
->
getCustomerOrderItemsByOrderId
(
$customer
[
'cus_id'
],
$order
[
'so_id'
]);
if
(
$orderDetail
)
{
foreach
(
$orderDetail
as
$detail
)
{
$si_discount
=
0
;
$si_amount
=
0
;
if
(
$detail
[
'p_id'
]
>
0
)
{
$si_discount
=
round
(
$detail
[
'si_price'
]
*
$discount
);
$si_amount
=
bcadd
(
$detail
[
'si_num'
],
$si_discount
);
$connection
->
table
(
'soitems'
)
->
where
(
'si_id'
,
$detail
[
'si_id'
])
->
update
([
'si_discount'
=>
$si_discount
,
'si_amount'
=>
$si_amount
]);
}
}
//更新订单总价
$total
=
$connection
->
table
(
'soitems'
)
->
where
(
'so_id'
,
$order
[
'so_id'
])
->
select
(
DB
::
raw
(
'sum(si_amount) as amount'
))
->
get
();
var_dump
(
$total
);
}
}
$connection
->
commit
();
}
}
catch
(
\Throwable
$exception
){
$connection
->
rollBack
();
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':updateCustomerOrdersPricesByDiscount'
,
'error'
);
}
}
}
}
}
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