lqmac 8 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){
//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) {
$collectorData = [
"key" => "collector",
"describe" => "商品采集设置",
"values" => json_decode('{"config":{"99api":{"apiKey":"9271DA7BF37C6F50BED49B7F0ADD49A2"}}}', true),
"store_id" => $store['store_id'],
"create_time" => time(),
"update_time" => time(),
];
$ret = Setting::create($collectorData);
echo "99api配置新增成功";
var_dump($ret->key);
}
// if (!$collector) {
// $collectorData = [
// "key" => "collector",
// "describe" => "商品采集设置",
// "values" => json_decode('{"config":{"99api":{"apiKey":"9271DA7BF37C6F50BED49B7F0ADD49A2"}}}', true),
// "store_id" => $store['store_id'],
// "create_time" => time(),
// "update_time" => time(),
// ];
// $ret = Setting::create($collectorData);
// echo "99api配置新增成功";
// var_dump($ret->key);
// }
//配送设置
$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\ModelNotFoundException
*/
public function collector(string $url, int $storeId): array
public function collector1(string $url, int $storeId): array
{
// 获取商品来源
$store = $this->getStore($url);
@ -430,7 +430,7 @@ class Collector extends BaseService
// echo "<pre>";
// print_r($item);
//exit();
// exit();
$item['goods_sku_no'] = $itemId;
return $item;
}
@ -444,7 +444,7 @@ class Collector extends BaseService
* @throws \think\db\exception\DbException
* @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);
@ -565,6 +565,7 @@ class Collector extends BaseService
'newSpecList' => [],
'newSkuList' => [],
'store_id' => $storeId,
'merchant_id' => $form['merchant_id'] ?? 0,
];
if (isset($form['channel'])) {
$data['channel'] = $form['channel'];
@ -638,6 +639,7 @@ class Collector extends BaseService
'newSpecList' => [],
'newSkuList' => [],
'store_id' => $storeId,
'merchant_id' => $form['merchant_id'] ?? 0,
];
if (isset($form['channel'])) {
$data['channel'] = $form['channel'];

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

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

Loading…
Cancel
Save