|
|
@@ -169,26 +169,24 @@ class Product extends BaseController
|
|
169
|
169
|
public function importStore(ProductService $productService)
|
|
170
|
170
|
{
|
|
171
|
171
|
$request = app('request');
|
|
172
|
|
- $id = $request->param('id', '');
|
|
173
|
|
- $ids = $request->param('ids', '');
|
|
|
172
|
+ $idStr = $request->param('id', '');
|
|
174
|
173
|
|
|
175
|
|
- // 解析要入库的ID列表
|
|
|
174
|
+ if (empty($idStr)) {
|
|
|
175
|
+ return json(['code' => 400, 'message' => '参数错误:请传入id']);
|
|
|
176
|
+ }
|
|
|
177
|
+
|
|
|
178
|
+ // 解析要入库的ID列表(支持单个id或逗号分隔的多个id)
|
|
176
|
179
|
$importIds = [];
|
|
177
|
|
- if (!empty($ids)) {
|
|
178
|
|
- $parts = explode(',', $ids);
|
|
179
|
|
- foreach ($parts as $part) {
|
|
180
|
|
- $part = (int)trim($part);
|
|
181
|
|
- if ($part > 0) $importIds[] = $part;
|
|
182
|
|
- }
|
|
183
|
|
- } elseif (!empty($id)) {
|
|
184
|
|
- $importIds[] = (int)$id;
|
|
|
180
|
+ $parts = explode(',', $idStr);
|
|
|
181
|
+ foreach ($parts as $part) {
|
|
|
182
|
+ $part = (int)trim($part);
|
|
|
183
|
+ if ($part > 0) $importIds[] = $part;
|
|
185
|
184
|
}
|
|
186
|
185
|
|
|
187
|
186
|
if (empty($importIds)) {
|
|
188
|
|
- return json(['code' => 400, 'message' => '参数错误:请传入id或ids']);
|
|
|
187
|
+ return json(['code' => 400, 'message' => '参数错误:id格式不正确']);
|
|
189
|
188
|
}
|
|
190
|
189
|
|
|
191
|
|
- // mer_id 写死 3447
|
|
192
|
190
|
$merId = $this->request->merId();;
|
|
193
|
191
|
|
|
194
|
192
|
$successList = [];
|