Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_api_initial
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
978c034e
authored
Apr 26, 2020
by
叶明星
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
更新登录中间件
parent
3dfc7e6b
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
279 additions
and
8 deletions
.env
.gitignore
.gitmodules
app/Http/Controllers/Controller.php
app/Http/Controllers/InStoreController.php
app/Http/routes.php
bootstrap/app.php
composer.json
config/website.php
app/Http/Middleware/CheckLogin.php → scm_wms_common/CheckLogin.php
scm_wms_common/SnModel.php
.env
View file @
978c034e
...
...
@@ -13,4 +13,5 @@ CACHE_DRIVER=memcached
QUEUE_DRIVER=sync
LOGIN_DOMAIN=user.liexin.net
ELK_NAME=liexin_scm_wms_api_in_store
\ No newline at end of file
ELK_NAME=liexin_scm_wms_api_in_store
IN_STORE_SERVICE_URL=http://192.168.2.239:40004
\ No newline at end of file
.gitignore
View file @
978c034e
/vendor
.env
.gitmodules
View file @
978c034e
[submodule "common"]
path = common
url = ssh://git@119.23.72.7:22611/yyc/Common.git
[submodule "scm_wms_common"]
path = scm_wms_common
url = ssh://git@119.23.72.7:22611/ymx/scm_wms_common.git
app/Http/Controllers/Controller.php
View file @
978c034e
...
...
@@ -14,4 +14,16 @@ class Controller extends BaseController
];
return
response
()
->
json
(
$response
);
}
public
function
curl
(
$Url
,
$data
,
$request
,
&
$response
=
''
){
$Domain
=
config
(
'website.IN_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
;
$response
=
curl
(
$warehousing_url
,
$data
,
true
);
return
json_decode
(
$response
,
true
);
}
}
app/Http/Controllers/InStoreController.php
0 → 100644
View file @
978c034e
<?php
namespace
App\Http\Controllers
;
use
App\Model\CountryModel
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Validator
;
class
InStoreController
extends
Controller
{
public
function
Entrance
(
Request
$request
,
$id
)
{
return
$this
->
$id
(
$request
,
$id
);
}
//获取入库详情
public
function
in_store_detail_list
(
$request
){
$collert
=
$request
->
only
(
'in_store_id'
);
//验证字段必填
$message
=
[
'required'
=>
'字段 :attribute 缺失'
];
$validator
=
Validator
::
make
(
$collert
,
[
'in_store_id'
=>
'required'
,
],
$message
);
if
(
$validator
->
fails
())
{
//必填验证不通过
return
$this
->
apiReturn
(
10001
,
$validator
->
errors
());
}
$list
=
$this
->
curl
(
'/in_store/get_detail_list'
,
$collert
,
$request
);
if
(
!
empty
(
$list
[
'data'
][
'data'
])
&&
is_array
(
$list
[
'data'
][
'data'
]))
{
foreach
(
$list
[
'data'
][
'data'
]
as
$k
=>
&
$v
)
{
$v
[
'wait_received'
]
=
bcsub
((
string
)
$v
[
'number'
],
(
string
)
$v
[
'receiving_number'
],
4
);
}
}
return
$this
->
apiReturn
(
array_get
(
$list
,
'errcode'
),
array_get
(
$list
,
'errmsg'
),
array_get
(
$list
,
'data'
));
}
//根据入仓单号获取入库单
public
function
get_warehousing_sn_in_store
(
$request
){
$collert
=
$request
->
only
([
'warehousing_sn'
]);
//验证字段必填
$message
=
[
'required'
=>
'字段 :attribute 缺失'
];
$validator
=
Validator
::
make
(
$collert
,
[
'warehousing_sn'
=>
'required'
,
],
$message
);
if
(
$validator
->
fails
())
{
//必填验证不通过
return
$this
->
apiReturn
(
10001
,
$validator
->
errors
());
}
$warehousing_url
=
'/in_store/get_in_store_warehousing_sn'
;
$list
=
$this
->
curl
(
$warehousing_url
,
$collert
,
$request
);
if
(
!
empty
(
$list
[
'data'
])
&&
is_array
(
$list
[
'data'
]))
{
foreach
(
$list
[
'data'
]
as
$k
=>
&
$v
)
{
if
(
$v
[
'status'
]
==
3
)
{
unset
(
$v
);
}
}
$list
[
'data'
]
=
array_values
(
$list
[
'data'
]);
}
return
$this
->
apiReturn
(
0
,
'ok'
,
[
'data'
=>
array_get
(
$list
,
'data'
)]);
}
//收货按钮
public
function
receiving_goods
(
$request
)
{
$field
=
[
'in_store_detail_id'
,
'number'
,
'box_num'
,
'country_id'
,
'batch'
,
'dc'
];
$collert
=
$request
->
only
(
$field
);
//验证字段必填
$message
=
[
'required'
=>
'字段 :attribute 缺失'
];
$validator
=
Validator
::
make
(
$collert
,
[
'in_store_detail_id'
=>
'required'
,
'number'
=>
'required'
,
'box_num'
=>
'required'
,
'country_id'
=>
'required'
,
],
$message
);
if
(
$validator
->
fails
())
{
//必填验证不通过
return
$this
->
apiReturn
(
10001
,
$validator
->
errors
());
}
$warehousing_url
=
'/in_store/receiving_goods'
;
$list
=
$this
->
curl
(
$warehousing_url
,
$collert
,
$request
);
return
$this
->
apiReturn
(
$list
[
'errcode'
],
$list
[
'errmsg'
],
array_get
(
$list
,
'data'
));
}
//产地扫码匹配
public
function
country_source
(
$request
)
{
$source
=
$request
->
input
(
'source'
);
$CountryModel
=
new
CountryModel
();
$Find
=
$CountryModel
->
where
(
'source'
,
'='
,
$source
)
->
orWhere
(
'country'
,
'='
,
$source
)
->
select
(
'country'
,
'country_id'
)
->
first
();
if
(
!
$Find
)
{
return
$this
->
apiReturn
(
10001
,
'没有找到匹配的产地'
);
}
$Find
=
$Find
->
toArray
();
return
$this
->
apiReturn
(
0
,
'OK'
,
[
'data'
=>
$Find
]);
}
//收货列表列表
public
function
receiving_list
(
$request
)
{
$field
=
[
'in_store_id'
,
'status'
,
'page'
,
'limit'
];
$collert
=
$request
->
only
(
$field
);
$warehousing_url
=
'/in_store/receiving_list'
;
$list
=
$this
->
curl
(
$warehousing_url
,
$collert
,
$request
);
if
(
!
empty
(
$list
[
'data'
])
&&
!
empty
(
$request
->
input
(
'is_mager'
)))
{
//需要合并相同型号
$data
=
[];
foreach
(
$list
[
'data'
]
as
$k
=>
$v
)
{
if
(
!
empty
(
$data
[
$v
[
'goods_id'
]]))
{
$data
[
$v
[
'goods_id'
]][
'number'
]
+=
$v
[
'number'
];
}
else
{
$data
[
$v
[
'goods_id'
]]
=
$v
;
}
}
$list
[
'data'
]
=
$data
;
}
return
$this
->
apiReturn
(
$list
[
'errcode'
],
$list
[
'errmsg'
],
[
'data'
=>
array_get
(
$list
,
'data'
)]);
}
//删除收货数据
public
function
delete_receiving
(
$request
)
{
$field
=
[
'receiving_id'
];
$collert
=
$request
->
only
(
$field
);
$warehousing_url
=
'/in_store/delete_receiving'
;
$result
=
$this
->
curl
(
$warehousing_url
,
$collert
,
$request
);
return
$this
->
apiReturn
(
$result
[
'errcode'
],
$result
[
'errmsg'
],
$result
[
'data'
]);
}
//修改收货的状态
public
function
update_receiving_status
(
$request
)
{
$field
=
[
'in_store_id'
,
'status'
,
'receiving_id'
,
'goods_id'
];
$collert
=
$request
->
only
(
$field
);
$warehousing_url
=
'/in_store/update_receiving_status'
;
$result
=
$this
->
curl
(
$warehousing_url
,
$collert
,
$request
);
return
$this
->
apiReturn
(
$result
[
'errcode'
],
$result
[
'errmsg'
],
$result
[
'data'
]);
}
//装箱以及散件
public
function
save_sale_task
(
$request
){
$field
=
[
'in_store_id'
,
'sale_type'
,
'box_sn'
,
'weight'
];
$collert
=
$request
->
only
(
$field
);
//判断必填
if
(
$collert
[
'sale_type'
]
===
'merge_box'
&&
empty
(
$collert
[
'box_sn'
])){
return
$this
->
apiReturn
(
10001
,
'请输入箱号'
);
}
if
(
$collert
[
'sale_type'
]
!==
'bulk'
&&
empty
(
$collert
[
'weight'
])){
return
$this
->
apiReturn
(
10002
,
'请先称重'
);
}
$warehousing_url
=
'/sale_task/save_sale_task'
;
$result
=
$this
->
curl
(
$warehousing_url
,
$collert
,
$request
);
return
$this
->
apiReturn
(
$result
[
'errcode'
],
$result
[
'errmsg'
],
$result
[
'data'
]);
}
}
app/Http/routes.php
View file @
978c034e
...
...
@@ -11,9 +11,17 @@
|
*/
$app
->
get
(
'/'
,
function
()
use
(
$app
)
{
return
$app
->
version
();
});
//$app->group(['middleware' => 'login','namespace'=>'App\Http\Controllers'], function () use ($app) {
//
//});
$app
->
get
(
'/'
,
function
()
use
(
$app
){
return
$app
->
version
();
});
return
$app
->
version
();
});
$app
->
get
(
'/test/index'
,
'ExampleController@index'
);
$app
->
post
(
'/in_store/{key}'
,
'InStoreController@Entrance'
);
bootstrap/app.php
View file @
978c034e
<?php
use
App\Http\Middleware\CheckLogin
;
use
App\Http\Middleware\UniqueMiddleware
;
use
Common\Exceptions\Handler
;
...
...
@@ -66,7 +67,7 @@ $app->singleton(
$app
->
middleware
([
// App\Http\Middleware\ExampleMiddleware::class
App\Http\Middleware\UniqueMiddleware
::
class
,
App\Http\Middleware
\CheckLogin
::
class
\ScmWmsCommon
\CheckLogin
::
class
]);
// $app->routeMiddleware([
...
...
composer.json
View file @
978c034e
...
...
@@ -16,7 +16,8 @@
"autoload"
:
{
"psr-4"
:
{
"App
\\
"
:
"app/"
,
"Common
\\
"
:
"common/"
"Common
\\
"
:
"common/"
,
"ScmWmsCommon
\\
"
:
"scm_wms_common/"
},
"files"
:
[
"common/function.php"
,
...
...
config/website.php
View file @
978c034e
<?php
return
[
'verification_token'
=>
'http://'
.
env
(
'LOGIN_DOMAIN'
,
''
)
.
'/pwd/me'
'verification_token'
=>
'http://'
.
env
(
'LOGIN_DOMAIN'
,
''
)
.
'/pwd/me'
,
'IN_STORE_SERVICE_URL'
=>
env
(
'IN_STORE_SERVICE_URL'
)
];
app/Http/Middleware
/CheckLogin.php
→
scm_wms_common
/CheckLogin.php
View file @
978c034e
<?php
namespace
App\Http\Middleware
;
namespace
ScmWmsCommon
;
use
Closure
;
...
...
@@ -35,6 +35,8 @@ class CheckLogin
$user
=
$ret
->
data
;
$request
->
user
=
$user
;
//还需要处理仓库
$request
->
store_id
=
1
;
return
$next
(
$request
);
}
...
...
scm_wms_common/SnModel.php
0 → 100644
View file @
978c034e
<?php
namespace
ScmWmsCommon
;
use
Illuminate\Database\Eloquent\Model
;
use
DB
;
class
SnModel
extends
Model
{
protected
$table
=
'numbering_rules'
;
public
$timestamps
=
false
;
public
function
__construct
(
$connection
=
false
)
{
parent
::
__construct
();
if
(
$connection
){
$this
->
connection
=
$connection
;
}
}
//单号
public
function
sn
(
$ruleCode
)
{
$str
=
DB
::
connection
(
$this
->
connection
)
->
transaction
(
function
()
use
(
$ruleCode
){
$data
=
$this
->
where
(
'rule_code'
,
$ruleCode
)
->
first
();
if
(
!
empty
(
$data
))
{
$data
=
$data
->
toArray
();
}
$str
=
$data
[
'rule_prefix'
];
$str_middle
=
''
;
$number
=
$data
[
'rule_suffix_number'
]
+
1
;
if
(
!
empty
(
$data
[
'rule_mask'
]))
{
$str_middle
=
date
(
$data
[
'rule_mask'
]);
}
$str
.=
$str_middle
;
if
(
$str_middle
!=
$data
[
'rule_mask_str'
])
{
//重置
$number
=
$data
[
'rule_suffix'
];
$save
[
'rule_mask_str'
]
=
$str_middle
;
}
if
(
$data
[
'rule_suffix_len'
]
>
0
)
{
$str
.=
$this
->
fillNum
(
$data
[
'rule_suffix_len'
],
$number
);
if
(
$number
!=
$data
[
'rule_suffix_number'
])
{
$save
[
'rule_suffix_number'
]
=
$number
;
}
if
(
isset
(
$save
))
{
$this
->
where
(
'rule_id'
,
$data
[
'rule_id'
])
->
update
(
$save
);
}
}
return
$str
;
});
return
$str
;
}
private
function
fillNum
(
$len
,
$num
)
{
$str
=
''
;
if
(
$len
>
0
)
{
$str
=
str_pad
(
$num
,
$len
,
'0'
,
0
);
}
return
$str
;
}
//生成单号
public
function
generateNumber
(
$codeId
)
{
return
$this
->
sn
(
$codeId
);
}
}
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