Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
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
48620242
authored
Mar 31, 2020
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整批量导入提示
parent
ef53ddf6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
8 deletions
app/Http/Controllers/AddOrderController.php
app/Http/Controllers/AddOrderController.php
View file @
48620242
...
...
@@ -780,21 +780,44 @@ Class AddOrderController extends Controller
$required_keys
=
array_keys
(
$required
);
// 必填项keys
$err
=
[
'errcode'
=>
0
,
'errmsg'
=>
'验证成功'
];
// 提示信息
$err
=
[];
// 提示信息
array_walk
(
$excel
,
function
(
$val
,
$key
)
use
(
$required
,
$required_keys
,
&
$err
,
$type
)
{
// 跳过第一条
if
(
$key
!=
0
)
{
if
(
$type
==
1
)
{
// 联营
if
(
strtolower
(
$val
[
'supplier_name'
])
==
'digikey'
&&
empty
(
$val
[
'id'
]))
{
$err
=
[
'errcode'
=>
3
,
'errmsg'
=>
'第'
.
$key
.
'行,供应商为digikey,SKUID不能为空'
]
;
if
(
$type
==
1
&&
strtolower
(
$val
[
'supplier_name'
])
==
'digikey'
)
{
// 联营
if
(
empty
(
$val
[
'id'
]))
{
$err
[]
=
'第'
.
$key
.
'行,供应商为digikey,SKUID不能为空'
;
return
;
}
$url
=
Config
(
'website.search-skuid'
);
$data
[
'id'
]
=
$val
[
'id'
];
$data
[
'k1'
]
=
time
();
$data
[
'k2'
]
=
md5
(
md5
(
$data
[
'k1'
])
.
'fh6y5t4rr351d2c3bryi'
);
$response
=
json_decode
(
curlApi
(
$url
,
$data
,
'POST'
),
true
);
if
(
empty
(
$response
[
'data'
])
||
empty
(
$response
[
'data'
][
'goods_id'
]))
{
$err
[]
=
'第'
.
$key
.
'行,供应商为digikey,未找SKU信息'
;
return
;
}
if
(
$response
[
'data'
][
'goods_name'
]
!=
$val
[
'goods_name'
])
{
$err
[]
=
'第'
.
$key
.
'行,供应商为digikey,商品名称不匹配'
;
return
;
}
if
(
$response
[
'data'
][
'brand_name'
]
!=
$val
[
'brand_name'
])
{
$err
[]
=
'第'
.
$key
.
'行,供应商为digikey,制造商不匹配'
;
return
;
}
}
foreach
(
$val
as
$k
=>
$v
)
{
if
(
in_array
(
$k
,
$required_keys
))
{
if
(
empty
(
$v
))
{
// 若必填项值为空,返回提示信息
$err
=
[
'errcode'
=>
1
,
'errmsg'
=>
$required
[
$k
]
.
'列,第'
.
$key
.
'行不能为空'
]
;
$err
[]
=
$required
[
$k
]
.
'列,第'
.
$key
.
'行不能为空'
;
break
;
}
}
...
...
@@ -802,15 +825,19 @@ Class AddOrderController extends Controller
// 自营ID、采购数量和单价为数字类型
if
(
$k
==
'id'
||
$k
==
'num'
||
$k
==
'goods_price'
)
{
if
(
!
preg_match
(
'/\d/'
,
$v
))
{
$err
=
[
'errcode'
=>
2
,
'errmsg'
=>
$required
[
$k
]
.
'列,第'
.
$key
.
'行格式错误'
]
;
$err
[]
=
$required
[
$k
]
.
'列,第'
.
$key
.
'行格式错误'
;
break
;
}
}
}
}
});
return
$err
;
if
(
!
empty
(
$err
))
{
return
[
'errcode'
=>
1
,
'errmsg'
=>
implode
(
'; '
,
$err
)];
}
return
[
'errcode'
=>
0
,
'errmsg'
=>
'验证成功'
];
}
// 处理导入内容---赋上字段
...
...
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