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
06cc8100
Commit
06cc8100
authored
Aug 29, 2022
by
hangjun83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
openapi 震坤行
parent
a1a1a7a9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
185 additions
and
3 deletions
+185
-3
server/app/Http/Controllers/V1/Controller.php
server/app/Http/Controllers/V1/Controller.php
+46
-0
server/app/Http/Controllers/V1/ZhenkhController.php
server/app/Http/Controllers/V1/ZhenkhController.php
+85
-0
server/app/Services/ThirdPlatform/Api/ZhenkhApiService.php
server/app/Services/ThirdPlatform/Api/ZhenkhApiService.php
+33
-1
server/app/Services/ZhenKhService.php
server/app/Services/ZhenKhService.php
+21
-2
No files found.
server/app/Http/Controllers/V1/Controller.php
0 → 100644
View file @
06cc8100
<?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
Jiannei\Response\Laravel\Support\Facades\Response
;
use
Jiannei\Response\Laravel\Support\Traits\ExceptionTrait
;
use
Laravel\Lumen\Routing\Controller
as
BaseController
;
abstract
class
Controller
extends
BaseController
{
use
ExceptionTrait
;
/**
* request 参数验证
* @param $request
* @param $message
* @return bool|\Illuminate\Http\JsonResponse
*/
protected
function
validateRequest
(
$request
,
$message
){
$validateArr
=
[];
collect
(
$message
)
->
map
(
function
(
$value
,
$key
)
use
(
&
$validateArr
){
$keys
=
explode
(
'.'
,
$key
);
$validateArr
[
$keys
[
0
]]
=
$keys
[
1
];
});
$validator
=
Validator
(
$request
->
all
(),
$validateArr
,
$message
);
if
(
$validator
->
fails
())
{
foreach
(
$validator
->
errors
()
->
getMessages
()
as
$error
)
{
return
Response
::
fail
(
$error
[
0
]);
}
}
return
true
;
}
}
server/app/Http/Controllers/V1/ZhenkhController.php
0 → 100644
View file @
06cc8100
<?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\ZhenKhService
;
use
Illuminate\Http\Request
;
use
Jiannei\Response\Laravel\Support\Facades\Response
;
use
App\Http\Controllers\V1\Controller
;
use
App\Support\Traits\Helpers
;
class
ZhenkhController
extends
Controller
{
use
Helpers
;
public
function
__construct
(
ZhenKhService
$zhenKhService
)
{
$this
->
zhenKhService
=
$zhenKhService
;
}
/**
* 震坤行订单发货
* @param Request $request
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Resources\Json\JsonResource
*/
public
function
orderDelivery
(
Request
$request
)
{
$message
=
[
'delivery_code.required'
=>
"发货单号必传"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$params
=
$request
->
all
();
$this
->
zhenKhService
->
sendDeliveryOrder
(
$params
[
'delivery_code'
]);
return
Response
::
success
(
null
,
'操作成功'
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
public
function
getOrderDeliveryPdf
(
Request
$request
)
{
$message
=
[
'delivery_code.required'
=>
"发货单号必传"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$params
=
$request
->
all
();
$this
->
zhenKhService
->
getDeliveryOrderPdf
(
$params
[
'delivery_code'
]);
return
Response
::
success
(
null
,
'操作成功'
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
public
function
orderConfirm
(
Request
$request
)
{
$message
=
[
'order_no.required'
=>
"发货单号必传"
,
];
$this
->
validateRequest
(
$request
,
$message
);
try
{
$params
=
$request
->
all
();
$result
=
$this
->
zhenKhService
->
orderConfirm
(
$params
[
'order_no'
]);
if
(
$result
){
return
Response
::
success
(
null
,
'操作成功'
);
}
return
Response
::
fail
(
'操作失败'
,
500
);
}
catch
(
\Exception
$exception
){
return
Response
::
fail
(
$exception
->
getMessage
(),
500
);
}
}
}
server/app/Services/ThirdPlatform/Api/ZhenkhApiService.php
View file @
06cc8100
...
...
@@ -255,6 +255,7 @@ class ZhenkhApiService extends PlatformAbstractService
}
/**
* @上报商品库存
* @param $params
* @param $token
* @return bool|mixed|void
...
...
@@ -266,7 +267,6 @@ class ZhenkhApiService extends PlatformAbstractService
}
try
{
if
(
$this
->
checkPlatformStatus
()){
$response
=
$this
->
getPostClient
(
$this
->
getPlatformApiUrl
()
.
'/openApi/v2/common/report/stock'
,
[[
'supplierWarehouseName'
=>
$params
[
'warehouse'
],
...
...
@@ -287,6 +287,12 @@ class ZhenkhApiService extends PlatformAbstractService
}
}
/**
* @获取送货单pdf
* @param $deliveryCode
* @param $token
* @return mixed|void
*/
public
function
getDeliveryOrderDetailForPDF
(
$deliveryCode
,
$token
)
{
try
{
...
...
@@ -312,6 +318,32 @@ class ZhenkhApiService extends PlatformAbstractService
}
}
/**
* @订单确认
* @param $orderNo
* @param $token
* @return bool|mixed|void
*/
public
function
orderConfirm
(
$orderNo
,
$token
)
{
try
{
if
(
$this
->
checkPlatformStatus
()){
$params
=
[];
$params
[
'purchaseOrderId'
]
=
$orderNo
;
$response
=
$this
->
getPostClient
(
$this
->
getPlatformApiUrl
()
.
'/openPoApi/v1/purchaseOrder/confirm'
,
$params
,
null
,
[
'honeycombToken'
=>
$token
,
'Content-Type'
=>
'application/json;charset=UTF-8'
]);
return
$this
->
apiResponse
(
$response
);
}
}
catch
(
\Exception
$exception
){
$this
->
requestError
(
$exception
);
}
}
protected
function
apiResponse
(
$response
)
{
$decodeResponse
=
json_decode
(
$response
,
true
);
...
...
server/app/Services/ZhenKhService.php
View file @
06cc8100
...
...
@@ -320,7 +320,7 @@ class ZhenKhService
}
}
catch
(
\Throwable
$exception
){
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
'
sendDeliveryOrder'
,
'error'
);
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':
sendDeliveryOrder'
,
'error'
);
}
}
...
...
@@ -343,6 +343,25 @@ class ZhenKhService
return
$pdf
[
'pdf'
];
}
/**
* @订单确认
* @param $orderNo
* @return bool|mixed|void
*/
public
function
orderConfirm
(
$orderNo
)
{
try
{
$orderDetail
=
$this
->
rhawnOrderService
->
getSorderDetail
(
$orderNo
);
if
(
$orderDetail
){
return
$this
->
apiService
->
orderConfirm
(
$orderDetail
[
'so_cus_po'
],
$this
->
getToken
());
}
return
false
;
}
catch
(
\Throwable
$exception
){
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':orderConfirm'
,
'error'
);
return
false
;
}
}
/**
* @ 获取api token
* @return false|mixed
...
...
@@ -370,7 +389,7 @@ class ZhenKhService
return
$token
[
'token'
];
}
}
catch
(
\Exception
$exception
){
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
'
token error'
,
'error'
);
SimpleLogs
::
writeLog
(
$exception
->
getMessage
(),
__CLASS__
.
':
token error'
,
'error'
);
return
false
;
}
}
...
...
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