Commit 48620242 by 朱继来

调整批量导入提示

parent ef53ddf6
Showing with 35 additions and 8 deletions
...@@ -780,21 +780,44 @@ Class AddOrderController extends Controller ...@@ -780,21 +780,44 @@ Class AddOrderController extends Controller
$required_keys = array_keys($required); // 必填项keys $required_keys = array_keys($required); // 必填项keys
$err = ['errcode' => 0, 'errmsg' => '验证成功']; // 提示信息 $err = []; // 提示信息
array_walk($excel, function($val, $key) use($required, $required_keys, &$err, $type) { array_walk($excel, function($val, $key) use($required, $required_keys, &$err, $type) {
// 跳过第一条 // 跳过第一条
if ($key != 0) { if ($key != 0) {
if ($type == 1) { // 联营 if ($type == 1 && strtolower($val['supplier_name']) == 'digikey') { // 联营
if (strtolower($val['supplier_name']) == 'digikey' && empty($val['id'])) { if (empty($val['id'])) {
$err = ['errcode' => 3, 'errmsg' => '第'.$key.'行,供应商为digikey,SKUID不能为空']; $err[] = '第'.$key.'行,供应商为digikey,SKUID不能为空';
return; 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) { foreach ($val as $k=>$v) {
if (in_array($k, $required_keys)) { if (in_array($k, $required_keys)) {
if (empty($v)) { // 若必填项值为空,返回提示信息 if (empty($v)) { // 若必填项值为空,返回提示信息
$err = ['errcode' => 1, 'errmsg' => $required[$k].'列,第'.$key.'行不能为空']; $err[] = $required[$k].'列,第'.$key.'行不能为空';
break; break;
} }
} }
...@@ -802,15 +825,19 @@ Class AddOrderController extends Controller ...@@ -802,15 +825,19 @@ Class AddOrderController extends Controller
// 自营ID、采购数量和单价为数字类型 // 自营ID、采购数量和单价为数字类型
if ($k == 'id' || $k == 'num' || $k == 'goods_price') { if ($k == 'id' || $k == 'num' || $k == 'goods_price') {
if (!preg_match('/\d/', $v)) { if (!preg_match('/\d/', $v)) {
$err = ['errcode' => 2, 'errmsg' => $required[$k].'列,第'.$key.'行格式错误']; $err[] = $required[$k].'列,第'.$key.'行格式错误';
break; break;
} }
} }
} }
} }
}); });
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