lqmac 10 months ago
parent a433bf0fc9
commit 6af7710799
  1. 28
      app/command/SyncStoreBasicData.php
  2. 8
      app/job/service/goods/Collector.php
  3. 4
      app/store/controller/goods/Collector.php
  4. 5
      app/store/model/goods/Import.php

@ -105,21 +105,21 @@ class SyncStoreBasicData extends Command
*/ */
private function syncStoreSettingData($store){ private function syncStoreSettingData($store){
//99api配置 //99api配置
$collector = Setting::where('key','collector')->where('store_id', $store['store_id'])->find(); // $collector = Setting::where('key','collector')->where('store_id', $store['store_id'])->find();
if (!$collector) { // if (!$collector) {
$collectorData = [ // $collectorData = [
"key" => "collector", // "key" => "collector",
"describe" => "商品采集设置", // "describe" => "商品采集设置",
"values" => json_decode('{"config":{"99api":{"apiKey":"9271DA7BF37C6F50BED49B7F0ADD49A2"}}}', true), // "values" => json_decode('{"config":{"99api":{"apiKey":"9271DA7BF37C6F50BED49B7F0ADD49A2"}}}', true),
"store_id" => $store['store_id'], // "store_id" => $store['store_id'],
"create_time" => time(), // "create_time" => time(),
"update_time" => time(), // "update_time" => time(),
]; // ];
$ret = Setting::create($collectorData); // $ret = Setting::create($collectorData);
echo "99api配置新增成功"; // echo "99api配置新增成功";
var_dump($ret->key); // var_dump($ret->key);
} // }
//配送设置 //配送设置
$delivery = Setting::where('key','delivery')->where('store_id', $store['store_id'])->find(); $delivery = Setting::where('key','delivery')->where('store_id', $store['store_id'])->find();

@ -414,7 +414,7 @@ class Collector extends BaseService
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
*/ */
public function collector(string $url, int $storeId): array public function collector1(string $url, int $storeId): array
{ {
// 获取商品来源 // 获取商品来源
$store = $this->getStore($url); $store = $this->getStore($url);
@ -430,7 +430,7 @@ class Collector extends BaseService
// echo "<pre>"; // echo "<pre>";
// print_r($item); // print_r($item);
//exit(); // exit();
$item['goods_sku_no'] = $itemId; $item['goods_sku_no'] = $itemId;
return $item; return $item;
} }
@ -444,7 +444,7 @@ class Collector extends BaseService
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
*/ */
public function collector1(string $url, int $storeId): array public function collector(string $url, int $storeId): array
{ {
// 获取商品来源 // 获取商品来源
$store = $this->getStore($url); $store = $this->getStore($url);
@ -565,6 +565,7 @@ class Collector extends BaseService
'newSpecList' => [], 'newSpecList' => [],
'newSkuList' => [], 'newSkuList' => [],
'store_id' => $storeId, 'store_id' => $storeId,
'merchant_id' => $form['merchant_id'] ?? 0,
]; ];
if (isset($form['channel'])) { if (isset($form['channel'])) {
$data['channel'] = $form['channel']; $data['channel'] = $form['channel'];
@ -638,6 +639,7 @@ class Collector extends BaseService
'newSpecList' => [], 'newSpecList' => [],
'newSkuList' => [], 'newSkuList' => [],
'store_id' => $storeId, 'store_id' => $storeId,
'merchant_id' => $form['merchant_id'] ?? 0,
]; ];
if (isset($form['channel'])) { if (isset($form['channel'])) {
$data['channel'] = $form['channel']; $data['channel'] = $form['channel'];

@ -45,9 +45,11 @@ class Collector extends Controller
*/ */
public function batch(): Json public function batch(): Json
{ {
$form = $this->postData();
$form['merchant_id'] = $this->merchantId;
// 新增记录 // 新增记录
$model = new CollectorModel; $model = new CollectorModel;
if ($model->batch($this->postData())) { if ($model->batch($form)) {
return $this->renderSuccess('已添加到采集任务中,请在采集记录中查看结果'); return $this->renderSuccess('已添加到采集任务中,请在采集记录中查看结果');
} }
return $this->renderError($model->getError() ?: '操作失败'); return $this->renderError($model->getError() ?: '操作失败');

@ -139,6 +139,7 @@ class Import extends ImportModel
self::$storeId = $form['store_id'] ?? 0; self::$storeId = $form['store_id'] ?? 0;
self::$merchantId = $form['merchant_id'] ?? 0; self::$merchantId = $form['merchant_id'] ?? 0;
foreach ($execlData as &$value) { foreach ($execlData as &$value) {
$value['channel'] = $form['channel']??'zy'; $value['channel'] = $form['channel']??'zy';
} }
@ -157,8 +158,8 @@ class Import extends ImportModel
// } // }
// //var_dump($info->goods_id); // //var_dump($info->goods_id);
// //exit(); // //exit();
// $data = $obj->createData($item, self::$storeId); // $data = $obj->createData($item, self::$storeId, self::$merchantId);
// $service->single1($item['D'], $data, self::$storeId); // $service->single($item['D'], $data, self::$storeId);
// exit(); // exit();
// // // 记录导入成功 // // // 记录导入成功
// // $this->successCount++; // // $this->successCount++;

Loading…
Cancel
Save