Commit 48620242 by 朱继来

调整批量导入提示

parent ef53ddf6
Showing with 34 additions and 7 deletions
......@@ -780,13 +780,36 @@ 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;
}
}
......@@ -794,7 +817,7 @@ Class AddOrderController extends Controller
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,7 +825,7 @@ 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;
}
}
......@@ -810,7 +833,11 @@ Class AddOrderController extends Controller
}
});
return $err;
if (!empty($err)) {
return ['errcode' => 1, 'errmsg' => implode('; ', $err)];
}
return ['errcode' => 0, 'errmsg' => '验证成功'];
}
// 处理导入内容---赋上字段
......
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