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
36251951
Commit
36251951
authored
Jun 06, 2022
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
罗恩工具类更新
parent
ba6f28e0
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1857 additions
and
1 deletion
+1857
-1
server/app/Http/Controllers/V1/RhawnOrdersController.php
server/app/Http/Controllers/V1/RhawnOrdersController.php
+204
-0
server/app/Jobs/RhawnSorderRefundJob.php
server/app/Jobs/RhawnSorderRefundJob.php
+86
-0
server/app/Providers/RepositoryServiceProvider.php
server/app/Providers/RepositoryServiceProvider.php
+3
-0
server/app/Repositories/Contracts/RhawnSoitemsRepository.php
server/app/Repositories/Contracts/RhawnSoitemsRepository.php
+21
-0
server/app/Repositories/Contracts/RhawnSorderRefundRepository.php
...pp/Repositories/Contracts/RhawnSorderRefundRepository.php
+21
-0
server/app/Repositories/Contracts/RhawnSordersRepository.php
server/app/Repositories/Contracts/RhawnSordersRepository.php
+21
-0
server/app/Repositories/Criteria/RhawnSorderRefundCriteria.php
...r/app/Repositories/Criteria/RhawnSorderRefundCriteria.php
+31
-0
server/app/Repositories/Eloquent/RhawnSoitemsRepositoryEloquent.php
.../Repositories/Eloquent/RhawnSoitemsRepositoryEloquent.php
+119
-0
server/app/Repositories/Eloquent/RhawnSorderRefundRepositoryEloquent.php
...sitories/Eloquent/RhawnSorderRefundRepositoryEloquent.php
+86
-0
server/app/Repositories/Eloquent/RhawnSordersRepositoryEloquent.php
.../Repositories/Eloquent/RhawnSordersRepositoryEloquent.php
+97
-0
server/app/Repositories/Models/RhawnSoitems.php
server/app/Repositories/Models/RhawnSoitems.php
+58
-0
server/app/Repositories/Models/RhawnSorderRefund.php
server/app/Repositories/Models/RhawnSorderRefund.php
+36
-0
server/app/Repositories/Models/RhawnSorders.php
server/app/Repositories/Models/RhawnSorders.php
+58
-0
server/app/Services/BhOrdersService.php
server/app/Services/BhOrdersService.php
+1
-1
server/app/Services/RhawnOrdersService.php
server/app/Services/RhawnOrdersService.php
+799
-0
server/app/Support/Traits/InitMenusAndPermission.php
server/app/Support/Traits/InitMenusAndPermission.php
+77
-0
server/config/database.php
server/config/database.php
+15
-0
server/database/seeds/local/RhSalesOrderRefundMenuSeeder.php
server/database/seeds/local/RhSalesOrderRefundMenuSeeder.php
+113
-0
server/routes/api/tools.php
server/routes/api/tools.php
+11
-0
No files found.
server/app/Http/Controllers/V1/RhawnOrdersController.php
0 → 100644
View file @
36251951
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Http\Controllers\V1
;
use
App\Services\RhawnOrdersService
;
use
Illuminate\Http\Request
;
use
Jiannei\Enum\Laravel\Repositories\Enums\LogEnum
;
use
Jiannei\Response\Laravel\Support\Facades\Response
;
use
App\Http\Controllers\V1\Controller
;
use
App\Support\Traits\Helpers
;
class
RhawnOrdersController
extends
Controller
{
use
Helpers
;
protected
$rhawnOrdersService
=
null
;
public
function
__construct
(
RhawnOrdersService
$rhawnOrdersService
)
{
$this
->
rhawnOrdersService
=
$rhawnOrdersService
;
}
/**
* 添加一个订单退货人任务
* @param Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
*/
public
function
addSorderRefundTask
(
Request
$request
)
{
$message
=
[
'name.required'
=>
"任务名称必填"
,
'orderNo.required'
=>
"订单号必填"
,
'itemId.required'
=>
"订单购买项必填"
,
'pId.required'
=>
"订单产品必选"
,
'handleFee.required'
=>
"手续费费用必填"
,
'transferPre.required'
=>
"是否转预存必选"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$order
=
$this
->
rhawnOrdersService
->
addSordersRefundTask
(
$request
);
return
Response
::
success
(
$order
,
'添加成功'
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
public
function
editSorderRefundTask
(
Request
$request
)
{
$message
=
[
'taskId.required'
=>
"任务id必填"
,
'name.required'
=>
"任务名称必填"
,
'orderNo.required'
=>
"订单号必填"
,
'itemId.required'
=>
"订单购买项必填"
,
'pId.required'
=>
"订单产品必选"
,
'refundNums.required'
=>
"退货数量必填"
,
'handleFee.required'
=>
"手续费费用必填"
,
'transferPre.required'
=>
"是否转预存必选"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$order
=
$this
->
rhawnOrdersService
->
addSordersRefundTask
(
$request
);
return
Response
::
success
(
$order
,
'编辑成功'
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
public
function
delSorderRefundTask
(
Request
$request
)
{
$message
=
[
'taskId.required'
=>
"任务id必传"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$task
=
$this
->
rhawnOrdersService
->
delSorderRefundTask
(
$request
);
return
Response
::
success
(
$task
,
'操作成功'
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
/**
* 获取订单退货任务列表
* @param Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
*/
public
function
getSorderRefundTaskToPage
(
Request
$request
)
{
$message
=
[
'type.required'
=>
"类型无效"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$task
=
$this
->
rhawnOrdersService
->
getSordersRefundTask
(
$request
);
return
Response
::
success
(
$task
,
'添加成功'
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
/**
* 获取库存数据
* @param Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
*/
public
function
getRhawnSordersStock
(
Request
$request
)
{
$message
=
[
'orderItemId.required'
=>
"id必传"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$task
=
$this
->
rhawnOrdersService
->
getSordersStock
(
$request
);
return
Response
::
success
(
$this
->
formatKeysfromArray
(
$task
),
'添加成功'
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
/**
* 执行罗恩退货任务
* @param Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
*/
public
function
execRhawnSorderRefundTask
(
Request
$request
)
{
$message
=
[
'taskId.required'
=>
"任务id必填"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$this
->
rhawnOrdersService
->
execSordersRefundTask
(
$request
);
return
Response
::
success
([],
'操作成功'
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
/**
* 查询订单详情
* @param Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
*/
public
function
getSordersDetail
(
Request
$request
)
{
$message
=
[
'orderNo.required'
=>
"订单号必填"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$order
=
$this
->
rhawnOrdersService
->
getSorderDetail
(
$request
);
return
Response
::
success
(
$this
->
formatKeysfromArray
(
$order
),
'更新成功'
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
public
function
getSorderRefundTaskLogsToPage
(
Request
$request
)
{
$message
=
[
'taskId.required'
=>
"任务id必填"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$logs
=
$this
->
rhawnOrdersService
->
getRhawnSorderTaskLog
(
$request
);
return
Response
::
success
(
$this
->
formatKeysfromArray
(
$logs
),
'操作成功'
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
public
function
getSorderDetailByTaskId
(
Request
$request
)
{
$message
=
[
'taskId.required'
=>
"任务id必填"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$logs
=
$this
->
rhawnOrdersService
->
getRhawnSorderDetailByTaskId
(
$request
);
return
Response
::
success
(
$this
->
formatKeysfromArray
(
$logs
),
'操作成功'
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
}
server/app/Jobs/RhawnSorderRefundJob.php
0 → 100644
View file @
36251951
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Jobs
;
use
App\Repositories\Contracts\RhawnSorderRefundRepository
;
use
App\Services\RhawnOrdersService
;
use
Illuminate\Support\Facades\DB
;
class
RhawnSorderRefundJob
extends
Job
{
protected
$refundInfo
;
public
function
__construct
(
$refundInfo
)
{
$this
->
refundInfo
=
$refundInfo
;
}
/**
* Execute the job.
*/
public
function
handle
()
{
try
{
app
(
RhawnSorderRefundRepository
::
class
)
->
update
([
'status'
=>
'running'
],
$this
->
refundInfo
[
'id'
]);
$note
=
null
;
$refundInfo
=
json_decode
(
$this
->
refundInfo
[
'exec_content'
]);
$service
=
app
(
RhawnOrdersService
::
class
);
$service
->
sOrderRefund
(
$refundInfo
,
$note
);
//对任务进行更新
$update
=
[];
$update
[
'status'
]
=
'finish'
;
$update
[
'exec_nums'
]
=
$this
->
refundInfo
[
'exec_nums'
]
+
1
;
$update
[
'error_message'
]
=
''
;
if
(
$note
&&
count
(
$note
)
>
0
){
$update
[
'error_message'
]
=
json_encode
(
$note
,
JSON_UNESCAPED_UNICODE
);
}
}
catch
(
\Exception
$e
){
//对任务进行更新
$update
=
[];
$update
[
'status'
]
=
'error'
;
$update
[
'error_message'
]
=
$e
->
getMessage
();
$update
[
'exec_nums'
]
=
intval
(
$this
->
refundInfo
[
'exec_nums'
]
+
1
);
}
try
{
$db
=
DB
::
connection
(
'mysql'
);
$db
->
beginTransaction
();
$update
[
'updated_at'
]
=
date
(
'Y-m-d H:i:s'
,
time
());
app
(
RhawnSorderRefundRepository
::
class
)
->
update
(
$update
,
$this
->
refundInfo
[
'id'
]);
$logInsert
=
[];
$logInsert
[
'task_id'
]
=
$this
->
refundInfo
[
'id'
];
if
(
isset
(
$update
[
'error_message'
])
&&
!
empty
(
$update
[
'error_message'
])){
$logInsert
[
'content'
]
=
$update
[
'error_message'
];
}
else
{
$logInsert
[
'content'
]
=
'执行完成'
;
}
$logInsert
[
'created_at'
]
=
date
(
'Y-m-d H:i:s'
,
time
());
$logInsert
[
'updated_at'
]
=
date
(
'Y-m-d H:i:s'
,
time
());
$db
->
table
(
'task_log'
)
->
insertGetId
(
$logInsert
);
$db
->
commit
();
}
catch
(
\Exception
$e
){
$db
->
rollback
();
throw
$e
;
}
}
}
server/app/Providers/RepositoryServiceProvider.php
View file @
36251951
...
...
@@ -28,6 +28,9 @@ class RepositoryServiceProvider extends LumenRepositoryServiceProvider
'App\Repositories\Contracts\BhSoitemsRepository'
=>
'App\Repositories\Eloquent\BhSoitemsRepositoryEloquent'
,
'App\Repositories\Contracts\BhSorderRefundRepository'
=>
'App\Repositories\Eloquent\BhSorderRefundRepositoryEloquent'
,
'App\Repositories\Contracts\ToolsTaskRepository'
=>
'App\Repositories\Eloquent\ToolsTaskRepositoryEloquent'
,
'App\Repositories\Contracts\RhawnSordersRepository'
=>
'App\Repositories\Eloquent\RhawnSordersRepositoryEloquent'
,
'App\Repositories\Contracts\RhawnSoitemsRepository'
=>
'App\Repositories\Eloquent\RhawnSoitemsRepositoryEloquent'
,
'App\Repositories\Contracts\RhawnSorderRefundRepository'
=>
'App\Repositories\Eloquent\RhawnSorderRefundRepositoryEloquent'
,
];
/**
...
...
server/app/Repositories/Contracts/RhawnSoitemsRepository.php
0 → 100644
View file @
36251951
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Repositories\Contracts
;
use
Prettus\Repository\Contracts\RepositoryInterface
;
/**
* Interface UserRepository.
*/
interface
RhawnSoitemsRepository
extends
RepositoryInterface
{
}
server/app/Repositories/Contracts/RhawnSorderRefundRepository.php
0 → 100644
View file @
36251951
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Repositories\Contracts
;
use
Prettus\Repository\Contracts\RepositoryInterface
;
/**
* Interface UserRepository.
*/
interface
RhawnSorderRefundRepository
extends
RepositoryInterface
{
}
server/app/Repositories/Contracts/RhawnSordersRepository.php
0 → 100644
View file @
36251951
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Repositories\Contracts
;
use
Prettus\Repository\Contracts\RepositoryInterface
;
/**
* Interface UserRepository.
*/
interface
RhawnSordersRepository
extends
RepositoryInterface
{
}
server/app/Repositories/Criteria/RhawnSorderRefundCriteria.php
0 → 100644
View file @
36251951
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Repositories\Criteria
;
use
Illuminate\Database\Eloquent\Builder
;
use
App\Repositories\Criteria\Criteria
;
class
RhawnSorderRefundCriteria
extends
Criteria
{
protected
function
condition
(
Builder
$query
)
:
void
{
if
(
$this
->
request
->
has
(
'type'
)){
$query
->
where
(
'type'
,
'='
,
$this
->
request
->
get
(
'type'
));
}
}
protected
function
after
(
$model
)
{
$model
->
orderbyDesc
(
'id'
);
return
$model
;
}
}
server/app/Repositories/Eloquent/RhawnSoitemsRepositoryEloquent.php
0 → 100644
View file @
36251951
<?php
namespace
App\Repositories\Eloquent
;
use
App\Repositories\Contracts\RhawnSoitemsRepository
;
use
App\Repositories\Contracts\RhawnSordersRepository
;
use
App\Repositories\Criteria\RequestCriteria
;
use
App\Repositories\Eloquent\BaseRepository
;
use
App\Repositories\Models\RhawnSoitems
;
use
Prettus\Validator\Contracts\ValidatorInterface
;
/**
* Class UserRepositoryEloquent.
*/
class
RhawnSoitemsRepositoryEloquent
extends
BaseRepository
implements
RhawnSoitemsRepository
{
protected
$fieldSearchable
=
[
];
/**
* Specify Model class name.
*
* @return string
*/
public
function
model
()
{
return
RhawnSoitems
::
class
;
}
/**
* Boot up the repository, pushing criteria.
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*/
public
function
boot
()
{
$this
->
pushCriteria
(
app
(
RequestCriteria
::
class
));
}
/**
* 获取订单详情
* @param $orderId
* @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection
*/
public
function
getSorderItemsDetailFromOrderId
(
$orderId
)
{
$order
=
app
(
RhawnSordersRepository
::
class
)
->
find
(
$orderId
);
if
(
!
$order
){
throw
new
\LogicException
(
'该订单不存在!'
,
500
);
}
//查询订单的详情
$soItems
=
RhawnSoitems
::
query
()
->
join
(
'products'
,
'soitems.p_id'
,
'products.p_id'
)
->
join
(
'chemicals'
,
'products.c_id'
,
'chemicals.c_id'
)
->
join
(
'brands'
,
'products.b_id'
,
'brands.b_id'
)
->
where
(
'soitems.so_id'
,
$order
->
so_id
)
->
get
();
return
$soItems
;
}
public
function
getSorderItemsDetailFromItemId
(
$itemId
,
$pid
=
null
)
{
//查询订单的详情
$soItems
=
RhawnSoitems
::
query
()
->
join
(
'sorders'
,
'sorders.so_id'
,
'soitems.so_id'
)
->
join
(
'products'
,
'soitems.p_id'
,
'products.p_id'
)
->
join
(
'chemicals'
,
'products.c_id'
,
'chemicals.c_id'
)
->
join
(
'brands'
,
'products.b_id'
,
'brands.b_id'
)
->
where
(
'soitems.si_id'
,
$itemId
);
if
(
!
is_null
(
$pid
)){
$soItems
=
$soItems
->
where
(
'soitems.p_id'
,
$pid
);
}
$soItems
=
$soItems
->
get
();
return
$soItems
;
}
/**
* 根据si_id获取订单明细项
* @param $si_id
* @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection
*/
public
function
getSorderItemFromItemId
(
$si_id
)
{
$item
=
$this
->
find
(
$si_id
);
if
(
!
$item
){
throw
new
\LogicException
(
'该订单项不存在!'
,
500
);
}
//查询订单的详情
$soItems
=
RhawnSoitems
::
query
()
->
join
(
'products'
,
'soitems.p_id'
,
'products.p_id'
)
->
where
(
'soitems.si_id'
,
$si_id
)
->
get
();
return
$soItems
;
}
public
function
getOrderItemsStockFromItemIds
(
$id
)
{
$item
=
$this
->
find
(
$id
);
if
(
!
$item
){
throw
new
\LogicException
(
'该订单项不存在!'
,
500
);
}
//查询订单的详情
$soItemStock
=
RhawnSoitems
::
query
()
->
join
(
'dpdetail'
,
'dpdetail.si_id'
,
'soitems.si_id'
)
->
join
(
'pstock'
,
'pstock.pstk_id'
,
'dpdetail.pstk_id'
)
->
join
(
'products'
,
'soitems.p_id'
,
'products.p_id'
)
->
where
(
'soitems.si_id'
,
$id
)
->
where
(
'si_if_cancel'
,
0
)
->
where
(
'dpdetail.dpd_invoiced'
,
'='
,
0
)
->
get
();
return
$soItemStock
;
}
}
server/app/Repositories/Eloquent/RhawnSorderRefundRepositoryEloquent.php
0 → 100644
View file @
36251951
<?php
namespace
App\Repositories\Eloquent
;
use
App\Repositories\Contracts\RhawnSorderRefundRepository
;
use
App\Repositories\Criteria\RequestCriteria
;
use
App\Repositories\Models\RhawnSorderRefund
;
use
App\Repositories\Eloquent\BaseRepository
;
use
Illuminate\Support\Facades\DB
;
use
Prettus\Validator\Contracts\ValidatorInterface
;
/**
* Class UserRepositoryEloquent.
*/
class
RhawnSorderRefundRepositoryEloquent
extends
BaseRepository
implements
RhawnSorderRefundRepository
{
protected
$fieldSearchable
=
[
];
/**
* Specify Model class name.
*
* @return string
*/
public
function
model
()
{
return
RhawnSorderRefund
::
class
;
}
/**
* Boot up the repository, pushing criteria.
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*/
public
function
boot
()
{
$this
->
pushCriteria
(
app
(
RequestCriteria
::
class
));
}
/**
* 添加退款任务
* @param $request
*/
public
function
addRefundTask
(
$params
)
{
if
(
empty
(
$params
)){
throw
new
\LogicException
(
'参数为空!'
,
500
);
}
$task
=
[];
$task
[
'name'
]
=
$params
[
'name'
];
unset
(
$params
[
'name'
]);
$task
[
'exec_content'
]
=
json_encode
(
$params
);
$task
[
'create_by'
]
=
auth
()
->
user
()
->
id
;
$task
[
'status'
]
=
'notexec'
;
$task
[
'type'
]
=
'rhawn_sorder_refund'
;
if
(
isset
(
$params
[
'task_id'
])
&&
!
empty
(
$params
[
'task_id'
])){
$id
=
$params
[
'task_id'
];
return
$this
->
update
(
$task
,
$id
);
}
else
{
return
$this
->
create
(
$task
);
}
}
public
function
delRefundTask
(
$params
)
{
if
(
empty
(
$params
)){
throw
new
\LogicException
(
'参数为空!'
,
500
);
}
DB
::
beginTransaction
();
try
{
$this
->
delete
(
$params
[
'task_id'
]);
DB
::
table
(
'task_log'
)
->
where
(
'task_id'
,
$params
[
'task_id'
])
->
delete
();
DB
::
commit
();
}
catch
(
\Exception
$e
){
DB
::
rollback
();
}
}
}
server/app/Repositories/Eloquent/RhawnSordersRepositoryEloquent.php
0 → 100644
View file @
36251951
<?php
namespace
App\Repositories\Eloquent
;
use
App\Repositories\Contracts\RhawnSordersRepository
;
use
App\Repositories\Criteria\RequestCriteria
;
use
App\Repositories\Models\RhawnSorders
;
use
App\Repositories\Eloquent\BaseRepository
;
use
Illuminate\Support\Facades\DB
;
use
Prettus\Validator\Contracts\ValidatorInterface
;
/**
* Class UserRepositoryEloquent.
*/
class
RhawnSordersRepositoryEloquent
extends
BaseRepository
implements
RhawnSordersRepository
{
protected
$fieldSearchable
=
[
];
/**
* Specify Model class name.
*
* @return string
*/
public
function
model
()
{
return
RhawnSorders
::
class
;
}
/**
* Boot up the repository, pushing criteria.
*
* @throws \Prettus\Repository\Exceptions\RepositoryException
*/
public
function
boot
()
{
$this
->
pushCriteria
(
app
(
RequestCriteria
::
class
));
}
/**
* 返回指定订单编号的订单信息
* @param $order_no
* @return mixed
*/
public
function
getSorderFromOrderNo
(
$orderNo
)
{
$where
=
[
'so_no'
=>
$orderNo
];
return
$this
->
findWhere
(
$where
)
->
first
();
}
/**
* 获取订单详情
* @param $orderNo
* @return mixed
*/
public
function
getSorderItemsFromOrderNo
(
$orderNo
){
$soItems
=
$this
->
join
(
'soitems'
,
'soitems.so_id'
,
'sorders.so_id'
)
->
where
(
'sorders.so_no'
,
$orderNo
)
->
get
();
return
$soItems
;
}
/**
* 获取订单相关信息(包括,产品,客户,品牌等)
* @param $so_id
* @return mixed
*/
public
function
getSorderDetailFromOrderId
(
$so_id
)
{
$sOrderInfo
=
$this
->
join
(
'customers'
,
'sorders.cus_id'
,
'customers.cus_id'
)
->
where
(
'sorders.so_id'
,
$so_id
)
->
get
();
if
(
!
$sOrderInfo
){
return
;
}
$sOrderInfo
=
current
(
$sOrderInfo
->
toArray
());
$items
=
DB
::
connection
(
'bh_mysql'
)
->
table
(
'soitems'
)
->
join
(
'products'
,
'soitems.p_id'
,
'products.p_id'
)
->
join
(
'chemicals'
,
'products.c_id'
,
'chemicals.c_id'
)
->
join
(
'brands'
,
'products.b_id'
,
'brands.b_id'
)
->
where
(
'soitems.so_id'
,
$so_id
)
->
get
();
if
(
!
$items
){
$sOrderInfo
[
'items'
]
=
[];
}
$sOrderInfo
[
'items'
]
=
$items
->
toArray
();
return
$sOrderInfo
;
}
}
server/app/Repositories/Models/RhawnSoitems.php
0 → 100644
View file @
36251951
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Repositories\Models
;
class
RhawnSoitems
extends
Model
{
// 销售订单
protected
$table
=
'soitems'
;
protected
$connection
=
'rhawn_mysql'
;
protected
$primaryKey
=
'si_id'
;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected
$fillable
=
[
];
protected
$guarded
=
[
'created_at'
,
'updated_at'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected
$hidden
=
[
];
/**
* update时不做自动更新时间操作
* @return null
*/
public
function
getUpdatedAtColumn
()
{
return
null
;
}
public
function
getCreatedAtColumn
()
{
return
null
;
}
}
\ No newline at end of file
server/app/Repositories/Models/RhawnSorderRefund.php
0 → 100644
View file @
36251951
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Repositories\Models
;
class
RhawnSorderRefund
extends
Model
{
protected
$table
=
'tools_task'
;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected
$fillable
=
[
'id'
,
'name'
,
'exec_content'
,
'status'
,
'error_message'
,
'type'
,
'exec_nums'
,
'create_by'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected
$hidden
=
[
];
}
\ No newline at end of file
server/app/Repositories/Models/RhawnSorders.php
0 → 100644
View file @
36251951
<?php
/*
* This file is part of the Jiannei/lumen-api-starter.
*
* (c) Jiannei <longjian.huang@foxmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
App\Repositories\Models
;
class
RhawnSorders
extends
Model
{
// 销售订单
protected
$table
=
'sorders'
;
protected
$connection
=
'rhawn_mysql'
;
protected
$primaryKey
=
'so_id'
;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected
$fillable
=
[
];
protected
$guarded
=
[
'created_at'
,
'updated_at'
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected
$hidden
=
[
];
/**
* update时不做自动更新时间操作
* @return null
*/
public
function
getUpdatedAtColumn
()
{
return
null
;
}
public
function
getCreatedAtColumn
()
{
return
null
;
}
}
\ No newline at end of file
server/app/Services/BhOrdersService.php
View file @
36251951
...
...
@@ -222,7 +222,7 @@ class BhOrdersService
$user
=
AdminUsers
::
find
(
$item
[
'create_by'
]);
$item
[
'create_by'
]
=
$user
->
username
;
$item
[
'content_string'
]
=
implode
(
'
.
'
,
$contentArr
);
$item
[
'content_string'
]
=
implode
(
'
<br / >
'
,
$contentArr
);
$item
=
array_merge
(
$item
,
$execArr
);
return
$item
;
});
...
...
server/app/Services/RhawnOrdersService.php
0 → 100644
View file @
36251951
This diff is collapsed.
Click to expand it.
server/app/Support/Traits/InitMenusAndPermission.php
0 → 100644
View file @
36251951
<?php
namespace
App\Support\Traits
;
use
App\Repositories\Contracts\MenusRepository
;
use
App\Repositories\Models\AdminUsers
;
use
App\Services\RoleAndPermissionsService
;
use
App\Repositories\Models\Menus
;
use
Illuminate\Support\Str
;
use
Spatie\Permission\Models\Permission
;
trait
InitMenusAndPermission
{
protected
$menusRepository
=
null
;
public
function
__construct
(
MenusRepository
$menusRepository
)
{
$this
->
menusRepository
=
$menusRepository
;
}
protected
function
initMenu
(
$menus
)
{
$menuModel
=
app
(
Menus
::
class
);
foreach
(
$menus
as
$menu
){
$parentMenu
=
$menuModel
->
where
(
'menu_name'
,
$menu
[
'parent_id'
])
->
first
();
if
(
!
$parentMenu
){
throw
new
\LogicException
(
'上级菜单不存在!'
,
500
);
}
if
(
'button'
==
$menu
[
'menu_type'
]){
$permission
=
Permission
::
query
()
->
where
([
'menu_id'
=>
0
,
'sys_default'
=>
1
,
'guard_name'
=>
config
(
'auth.defaults.guard'
),
'action'
=>
$menu
[
'action'
]])
->
first
();
if
(
!
$permission
){
throw
new
\LogicException
(
'按钮动作不存在!'
,
500
);
}
}
$filterParams
=
[];
collect
(
$this
->
menusRepository
->
rules
[
'create'
])
->
map
(
function
(
$rule
,
$key
)
use
(
$menu
,
&
$filterParams
){
if
(
isset
(
$menu
[
$key
])
&&
!
empty
(
$menu
[
$key
])){
$filterParams
[
$key
]
=
$menu
[
$key
];
}
else
{
$filterParams
[
$key
]
=
''
;
}
});
$filterParams
[
'parent_id'
]
=
$parentMenu
[
'id'
];
$filterParams
[
'menu_icon'
]
=
$menu
[
'menu_icon'
];
$filterParams
[
'component'
]
=
$menu
[
'component'
];
$filterParams
[
'created_by'
]
=
1
;
$filterParams
[
'status'
]
=
intval
(
$menu
[
'status'
]);
$result
=
$this
->
menusRepository
->
create
(
$filterParams
);
if
(
$result
){
$permission
=
[];
$permission
[
'name'
]
=
$result
[
'menu_name'
];
$permission
[
'menu_id'
]
=
$result
[
'id'
];
if
(
isset
(
$menu
[
'menu_type'
])
&&
!
empty
(
$menu
[
'menu_type'
])
&&
'button'
==
$menu
[
'menu_type'
]){
$permission
[
'action'
]
=
$menu
[
'menu_name'
];
$permission
[
'permission_type'
]
=
'button'
;
}
else
{
$permission
[
'permission_type'
]
=
'menu'
;
$permission
[
'action'
]
=
$menu
[
'menu_name'
]
.
'_list'
;
}
$permission
[
'sys_default'
]
=
0
;
$permission
[
'remark'
]
=
$result
[
'menu_name'
]
.
'的相关权限'
;
$permission
[
'guard_name'
]
=
config
(
'auth.defaults.guard'
);
//增加对应的按钮权限
$permissionResult
=
Permission
::
create
(
$permission
);
if
(
$permissionResult
){
$user
=
app
(
AdminUsers
::
class
)
->
where
(
'id'
,
1
)
->
get
()
->
first
();
app
(
RoleAndPermissionsService
::
class
)
->
assignRoleAndPermissionToUser
(
$permissionResult
,
$user
);
}
}
}
}
}
server/config/database.php
View file @
36251951
...
...
@@ -76,6 +76,21 @@ return [
'engine'
=>
env
(
'BH_DB_ENGINE'
,
null
),
'timezone'
=>
env
(
'BH_DB_TIMEZONE'
,
'+00:00'
),
],
'rhawn_mysql'
=>
[
'driver'
=>
'mysql'
,
'host'
=>
env
(
'RHAWN_DB_HOST'
,
'127.0.0.1'
),
'port'
=>
env
(
'RHAWN_DB_PORT'
,
3306
),
'database'
=>
env
(
'RHAWN_DB_DATABASE'
,
'forge'
),
'username'
=>
env
(
'RHAWN_DB_USERNAME'
,
'forge'
),
'password'
=>
env
(
'RHAWN_DB_PASSWORD'
,
''
),
'unix_socket'
=>
env
(
'RHAWN_DB_SOCKET'
,
''
),
'charset'
=>
env
(
'RHAWN_DB_CHARSET'
,
'utf8mb4'
),
'collation'
=>
env
(
'RHAWN_DB_COLLATION'
,
'utf8mb4_unicode_ci'
),
'prefix'
=>
env
(
'RHAWN_DB_PREFIX'
,
''
),
'strict'
=>
env
(
'RHAWN_DB_STRICT_MODE'
,
true
),
'engine'
=>
env
(
'RHAWN_DB_ENGINE'
,
null
),
'timezone'
=>
env
(
'RHAWN_DB_TIMEZONE'
,
'+00:00'
),
],
'pgsql'
=>
[
'driver'
=>
'pgsql'
,
...
...
server/database/seeds/local/RhSalesOrderRefundMenuSeeder.php
0 → 100644
View file @
36251951
<?php
use
App\Support\Traits\InitMenusAndPermission
;
use
Illuminate\Database\Seeder
;
use
Illuminate\Support\Facades\DB
;
class
RhSalesOrderRefundMenuSeeder
extends
Seeder
{
use
InitMenusAndPermission
;
public
function
run
()
{
//$this->command->getOutput()->info('正在初始化菜单数据中.');
try
{
DB
::
beginTransaction
();
// 初始化菜单及权限
$menus
=
[
[
'menu_name'
=>
'rhawn_sorder_refund'
,
'title'
=>
'罗恩销售订单退货'
,
'menu_path'
=>
'/tools/rhawn-sorder-refund'
,
'parent_id'
=>
'tools'
,
'menu_type'
=>
'page'
,
'menu_icon'
=>
'ios-laptop'
,
'component'
=>
'tools/rhawn/sorders-refund'
,
'status'
=>
1
,
'is_show'
=>
1
,
'sys_default'
=>
1
,
'sort'
=>
1.0
,
'created_by'
=>
0
,
'created_at'
=>
''
,
'updated_at'
=>
''
,
'action'
=>
''
,
],[
'menu_name'
=>
'rhawn_sorder_refund_add'
,
'title'
=>
'添加任务'
,
'menu_path'
=>
'#'
,
'parent_id'
=>
'rhawn_sorder_refund'
,
'menu_type'
=>
'button'
,
'menu_icon'
=>
'#'
,
'component'
=>
'#'
,
'status'
=>
1
,
'is_show'
=>
1
,
'sys_default'
=>
1
,
'sort'
=>
1.0
,
'created_by'
=>
0
,
'created_at'
=>
''
,
'updated_at'
=>
''
,
'action'
=>
'add'
,
],[
'menu_name'
=>
'rhawn_sorder_refund_edit'
,
'title'
=>
'编辑任务'
,
'menu_path'
=>
'#'
,
'parent_id'
=>
'rhawn_sorder_refund'
,
'menu_type'
=>
'button'
,
'menu_icon'
=>
'#'
,
'component'
=>
'#'
,
'status'
=>
1
,
'is_show'
=>
1
,
'sys_default'
=>
1
,
'sort'
=>
1.0
,
'created_by'
=>
0
,
'created_at'
=>
''
,
'updated_at'
=>
''
,
'action'
=>
'edit'
,
],[
'menu_name'
=>
'rhawn_sorder_refund_delete'
,
'title'
=>
'删除任务'
,
'menu_path'
=>
'#'
,
'parent_id'
=>
'rhawn_sorder_refund'
,
'menu_type'
=>
'button'
,
'menu_icon'
=>
'#'
,
'component'
=>
'#'
,
'status'
=>
1
,
'is_show'
=>
1
,
'sys_default'
=>
1
,
'sort'
=>
1.0
,
'created_by'
=>
0
,
'created_at'
=>
''
,
'updated_at'
=>
''
,
'action'
=>
'delete'
,
],[
'menu_name'
=>
'rhawn_sorder_refund_execute'
,
'title'
=>
'执行任务'
,
'menu_path'
=>
'#'
,
'parent_id'
=>
'rhawn_sorder_refund'
,
'menu_type'
=>
'button'
,
'menu_icon'
=>
'#'
,
'component'
=>
'#'
,
'status'
=>
1
,
'is_show'
=>
1
,
'sys_default'
=>
1
,
'sort'
=>
1.0
,
'created_by'
=>
0
,
'created_at'
=>
''
,
'updated_at'
=>
''
,
'action'
=>
'other'
,
],
];
$this
->
initMenu
(
$menus
);
DB
::
commit
();
$this
->
command
->
getOutput
()
->
info
(
'菜单数据初始化成功.'
);
}
catch
(
Exception
$e
){
$this
->
command
->
getOutput
()
->
error
(
'初始化菜单失败,原因:'
.
$e
->
getMessage
());
DB
::
rollback
();
}
}
}
server/routes/api/tools.php
View file @
36251951
...
...
@@ -29,6 +29,17 @@ $api->version('v1', function($api) {
$api
->
post
(
'/adminapi/tools/bh/delSorderRefundTask'
,
[
'permission'
=>
'tools.bh.order.search'
,
'uses'
=>
'BhOrdersController@delSorderRefundTask'
]);
$api
->
post
(
'/adminapi/tools/bh/getSorderDetailByTaskId'
,
[
'permission'
=>
'tools.bh.order.search'
,
'uses'
=>
'BhOrdersController@getSorderDetailByTaskId'
]);
// 罗恩销售订单
$api
->
post
(
'/adminapi/tools/rhawn/addSorderRefundTask'
,
[
'permission'
=>
'tools.rhawn.order.add'
,
'uses'
=>
'RhawnOrdersController@addSorderRefundTask'
]);
$api
->
post
(
'/adminapi/tools/rhawn/editSorderRefundTask'
,
[
'permission'
=>
'tools.rhawn.order.add'
,
'uses'
=>
'RhawnOrdersController@editSorderRefundTask'
]);
$api
->
post
(
'/adminapi/tools/rhawn/getSordersDetail'
,
[
'permission'
=>
'tools.rhawn.order.search'
,
'uses'
=>
'RhawnOrdersController@getSordersDetail'
]);
$api
->
get
(
'/adminapi/tools/rhawn/getRhawnSordersStock'
,
[
'permission'
=>
'tools.rhawn.order.search'
,
'uses'
=>
'RhawnOrdersController@getRhawnSordersStock'
]);
$api
->
get
(
'/adminapi/tools/rhawn/getSorderRefundTask'
,
[
'permission'
=>
'tools.rhawn.order.search'
,
'uses'
=>
'RhawnOrdersController@getSorderRefundTaskToPage'
]);
$api
->
post
(
'/adminapi/tools/rhawn/execRhawnSorderRefundTask'
,
[
'permission'
=>
'tools.rhawn.order.search'
,
'uses'
=>
'RhawnOrdersController@execRhawnSorderRefundTask'
]);
$api
->
get
(
'/adminapi/tools/rhawn/getSorderRefundTaskLogs'
,
[
'permission'
=>
'tools.rhawn.order.search'
,
'uses'
=>
'RhawnOrdersController@getSorderRefundTaskLogsToPage'
]);
$api
->
post
(
'/adminapi/tools/rhawn/delSorderRefundTask'
,
[
'permission'
=>
'tools.rhawn.order.search'
,
'uses'
=>
'RhawnOrdersController@delSorderRefundTask'
]);
$api
->
post
(
'/adminapi/tools/rhawn/getSorderDetailByTaskId'
,
[
'permission'
=>
'tools.rhawn.order.search'
,
'uses'
=>
'RhawnOrdersController@getSorderDetailByTaskId'
]);
});
});
...
...
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