批量导入新增商户id

feature/main20240421
lqmac 6 months ago
parent 9171cf371c
commit dca688ca7d
  1. 4
      app/admin/model/Store.php
  2. 2
      app/job/controller/goods/GoodsStoreImport.php
  3. 4
      app/job/service/goods/GoodsStoreImport.php
  4. 5
      app/store/controller/goods/Import.php
  5. 4
      app/store/model/goods/Import.php
  6. 3
      config/allowapi.php
  7. 2
      cores/BaseModel.php

@ -93,8 +93,8 @@ class Store extends StoreModel
'parent_id' => 0,
'sort' => 100,
'menus' => [
10034,10035,10204,10038,10036,10037,10141,10043,10044,10045,
10046,10047,10048,10049,10243,10244,10246,10245,10050,10051,
10034,10035,10204,10038,10036,10037,10141,10044,10045,
10046,10243,10244,10246,10245,10050,10051,
10052,10205,10054,10189,10055,10223,10139,10252,10056,10058,
10059,10057,10201,10238,10241,10239,10240,10242,10202,10203,
10206,10207,10208,10209,10213,10210,10211,10115

@ -44,6 +44,6 @@ class GoodsStoreImport extends BaseJob
echo "\n ---- adminImport ---- {$time} ---- \n";
$service = new GoodsStoreImportService;
return $service->batch($data['list'], $data['recordId'], $data['storeId']);
return $service->batch($data['list'], $data['recordId'], $data['storeId'], $data['merchantId']);
}
}

@ -99,12 +99,12 @@ class GoodsStoreImport extends BaseService
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function batch(array $list, int $recordId, int $storeId): bool
public function batch(array $list, int $recordId, int $storeId, int $merchantId): bool
{
$service = new \app\job\service\goods\Collector();
foreach ($list as $item) {
//sku存在了就不抓取了
$info = GoodsModel::where('goods_no', $item['C'])->where('store_id', $storeId)->where('channel', $item['channel'])->where('is_delete',0)->find();
$info = GoodsModel::where('goods_no', $item['C'])->where('store_id', $storeId)->where('merchant_id', $merchantId)->where('channel', $item['channel'])->where('is_delete',0)->find();
if ($info) {
$this->successCount++;
continue;

@ -32,7 +32,9 @@ class Import extends Controller
public function list(): Json
{
$model = new ImportModel;
$list = $model->getList($this->request->param());
$params = $this->request->param();
$params['merchant_id'] = $this->merchantId;
$list = $model->getList($params);
return $this->renderSuccess(compact('list'));
}
@ -47,6 +49,7 @@ class Import extends Controller
{
$form = $this->postData();
$form['store_id'] = $this->storeId;
$form['merchant_id'] = $this->merchantId;
// 新增记录
$model = new ImportModel;
if ($model->storeBatch($form)) {

@ -66,6 +66,7 @@ class Import extends ImportModel
$filter = [];
$params['status'] > -1 && $filter[] = ['status', '=', (int)$params['status']];
isset($params['store_id']) && $params['store_id'] > -1 && $filter[] = ['store_id', '=', (int)$params['store_id']];
isset($params['merchant_id']) && $params['merchant_id'] > -1 && $filter[] = ['merchant_id', '=', (int)$params['merchant_id']];
return $filter;
}
/**
@ -137,6 +138,7 @@ class Import extends ImportModel
$this->checkLimit($execlData);
self::$storeId = $form['store_id'] ?? 0;
self::$merchantId = $form['merchant_id'] ?? 0;
foreach ($execlData as &$value) {
$value['channel'] = $form['channel']??'zy';
}
@ -409,6 +411,7 @@ class Import extends ImportModel
'list' => $data,
'recordId' => $recordId,
'storeId' => self::$storeId,
'merchantId' => self::$merchantId,
]);
}
}
@ -472,6 +475,7 @@ class Import extends ImportModel
'fail_log' => [],
'status' => GoodsImportStatusEnum::NORMAL,
'store_id' => self::$storeId,
'merchant_id' => self::$merchantId,
'channel' => $channel,
]);
return (int)$this['id'];

@ -1,4 +1,5 @@
<?php
return [
"/store/platformList"
"/store/platformList",
"/setting.printer/all",
];

@ -33,6 +33,8 @@ abstract class BaseModel extends Model
// 当前访问的商城ID
public static ?int $storeId;
public static ?int $merchantId;
// 定义表名
protected $name;

Loading…
Cancel
Save