Commit 5b65c4c2 by Joneq

增加出库接口

parent e1d1512a
......@@ -2,11 +2,26 @@
namespace App\Http\Controllers;
use App\Http\Logic\CommonLogic;
use Laravel\Lumen\Routing\Controller as BaseController;
class Controller extends BaseController
{
public function apiReturn($errcode = 0, $errmsg = 'OK', $dataArr = []){
public function returnJson($data)
{
if (is_array($data)){
return $this->apiReturn(0,'OK',$data);
}
//设置默认错误code
if (empty(CommonLogic::$errCode)){
CommonLogic::$errCode = 1;
}
return $this->apiReturn(CommonLogic::$errCode,$data,[]);
}
public function apiReturn($errcode = 0, $errmsg = 'OK', $dataArr = [])
{
$response = [
'errcode' => $errcode,
'errmsg' => $errmsg,
......@@ -15,15 +30,15 @@ class Controller extends BaseController
return response()->json($response);
}
public function curl($Url, $data, $request, &$response = ''){
$Domain = config('website.IN_STORE_SERVICE_URL');
public function curl($Url, $data, $request, &$response = '')
{
$Domain = config('website.OUT_STORE_SERVICE_URL');
$warehousing_url = $Domain . $Url;
$data['admin_id'] = $request->user->userId;
$data['admin_name'] = $request->user->name;
$data['store_id'] = $request->store_id;
// $data['admin_id'] = $request->user->userId;
// $data['admin_name'] = $request->user->name;
// $data['store_id'] = $request->store_id;
$response = curl($warehousing_url, $data, true);
return json_decode($response, true);
return json_decode($response, true);
}
}
......@@ -2,7 +2,6 @@
namespace App\Http\Controllers;
use App\Model\CountryModel;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
......
<?php
/**
* Created by 2020/4/28.
* User: Joneq
* Info: 2020/4/28
* Time: 上午11:31
*/
namespace App\Http\Controllers;
use App\Http\Logic\CommonLogic;
use Illuminate\Http\Request;
class OutStoreController extends Controller
{
public function Entrance(Request $request, $id)
{
CommonLogic::$errCode = 0;
return $this->$id($request, $id);
}
//获取拣货列表
public function pick_task_list($request)
{
$data = $request->all();
try{
CommonLogic::checkEmpty(['location_id','pick_task_sn'],$data);
$returnData = $this->curl('/pick_task/getFrontPickTaskList',$data,$request);
if (!isset($returnData['errcode']) && !empty($returnData['errcode'])){
CommonLogic::$errCode = $returnData['errcode'];
throw new \Exception($returnData['data']);
}
}catch (\Exception $exception){
return $this->returnJson($exception->getMessage());
}
return $this->returnJson($returnData['data']);
}
//拣货确认
public function confirm_pick($request)
{
$data = $request->all();
try{
CommonLogic::checkEmpty(['location_id','pick_task_sn','goods_sn'],$data);
$returnData = $this->curl('/pick_task/confirmPick',$data,$request);
if (!isset($returnData['errcode']) && !empty($returnData['errcode'])){
CommonLogic::$errCode = $returnData['errcode'];
throw new \Exception($returnData['data']);
}
}catch (\Exception $exception){
return $this->returnJson($exception->getMessage());
}
return $this->returnJson($returnData['data']);
}
//获取卡板信息
public function pallet_box_list($request)
{
$data = $request->all();
try{
CommonLogic::checkEmpty(['pallet_id'],$data);
$returnData = $this->curl('/out_store/palletBoxList',$data,$request);
if (!isset($returnData['errcode']) && !empty($returnData['errcode'])){
CommonLogic::$errCode = $returnData['errcode'];
throw new \Exception($returnData['data']);
}
}catch (\Exception $exception){
return $this->returnJson($exception->getMessage());
}
return $this->returnJson($returnData['data']);
}
//装卡板
public function pallet_active($request)
{
$data = $request->all();
try{
CommonLogic::checkEmpty(['box_id_arr','pallet_sn'],$data);
$returnData = $this->curl('/out_store/palletActive',$data,$request);
if (isset($returnData['errcode']) && !empty($returnData['errcode'])){
CommonLogic::$errCode = $returnData['errcode'];
throw new \Exception($returnData['data']);
}
}catch (\Exception $exception){
return $this->returnJson($exception->getMessage());
}
return $this->returnJson($returnData['data']);
}
//扫描出库
public function scan_out_store($request)
{
}
}
\ No newline at end of file
<?php
/**
* Created by 2020/4/28.
* User: Joneq
* Info: 2020/4/28
* Time: 下午4:17
*/
namespace App\Http\Logic;
class CommonLogic
{
static public $errCode = 0;
//检测值是否为空
static public function checkEmpty($key,$data)
{
foreach ($key as $value){
if (!isset($data[$value]) || is_null($data[$value])){
self::$errCode = 1;
throw new \Exception($value.' is null');
}
}
}
}
\ No newline at end of file
......@@ -25,3 +25,4 @@ $app->get('/',function ()use($app){
});
$app->get('/test/index','ExampleController@index');
$app->post('/in_store/{key}','InStoreController@Entrance');
$app->post('/out_store/{key}','OutStoreController@Entrance');
......@@ -2,6 +2,6 @@
return [
'verification_token' => 'http://' . env('LOGIN_DOMAIN', '') . '/pwd/me',
'IN_STORE_SERVICE_URL' => env('IN_STORE_SERVICE_URL')
'OUT_STORE_SERVICE_URL' => env('OUT_STORE_SERVICE_URL')
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment