lqmac 7 months ago
parent 565460b1a9
commit aba812933c
  1. 23
      app/api/controller/Goods.php
  2. 47
      app/command/SyncStoreBasicData.php
  3. 69
      app/common/enum/goods/GoodsDeliveryTime.php
  4. 6
      app/job/service/goods/Collector.php

@ -15,10 +15,8 @@ namespace app\api\controller;
use app\api\model\{Goods as GoodsModel, Store as StoreModel}; use app\api\model\{Goods as GoodsModel, Store as StoreModel};
use app\api\model\Region; use app\api\model\Region;
use app\api\service\{Goods as GoodsService, User as UserService}; use app\api\service\{Goods as GoodsService, User as UserService};
use app\common\library\wechat\ShortLink;
use app\common\model\GoodsImage as GoodsImageModel; use app\common\model\GoodsImage as GoodsImageModel;
use app\common\model\UploadFile as UploadFileModel; use app\common\model\UploadFile as UploadFileModel;
use app\common\model\wxapp\Setting as WxappSettingModel;
use app\common\service\qrcode\Goods as GoodsPoster; use app\common\service\qrcode\Goods as GoodsPoster;
use cores\exception\BaseException; use cores\exception\BaseException;
use think\db\exception\DbException; use think\db\exception\DbException;
@ -99,6 +97,7 @@ class Goods extends Controller
'state' => "无货", 'state' => "无货",
'goods_name' => $goods['goods_name'], 'goods_name' => $goods['goods_name'],
'goods_id' => $goods['goods_id'], 'goods_id' => $goods['goods_id'],
'promise_info' => "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']] ?? "72小时")."内发货",
]; ];
$return[] = $data; $return[] = $data;
continue; continue;
@ -112,6 +111,7 @@ class Goods extends Controller
$data = $suning->shoppingCartPrice([$goods->toArray()], $city->sn_code, $district->sn_code); $data = $suning->shoppingCartPrice([$goods->toArray()], $city->sn_code, $district->sn_code);
$data['goods_name'] = $goods['goods_name']; $data['goods_name'] = $goods['goods_name'];
$data['goods_id'] = $goods['goods_id']; $data['goods_id'] = $goods['goods_id'];
$data['promise_info'] = "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']] ?? "72小时")."内发货";
break; break;
case 'jd': case 'jd':
case 'jd1': case 'jd1':
@ -134,6 +134,7 @@ class Goods extends Controller
'state' => $res, 'state' => $res,
'goods_name' => $goods['goods_name'], 'goods_name' => $goods['goods_name'],
'goods_id' => $goods['goods_id'], 'goods_id' => $goods['goods_id'],
'promise_info' => $ret['promiseInfo'] ?? "预计72小时内发货",
]; ];
break; break;
default: default:
@ -144,6 +145,7 @@ class Goods extends Controller
'state' => $res, 'state' => $res,
'goods_name' => $goods['goods_name'], 'goods_name' => $goods['goods_name'],
'goods_id' => $goods['goods_id'], 'goods_id' => $goods['goods_id'],
'promise_info' => "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']] ?? "72小时")."内发货",
]; ];
break; break;
@ -385,22 +387,5 @@ class Goods extends Controller
return $this->renderSuccess(['imageUrl' => $Qrcode->getImage()]); return $this->renderSuccess(['imageUrl' => $Qrcode->getImage()]);
} }
public function shortUrl(): Json
{
$page_url = $this->request->post('page_url');
if (empty($page_url)) {
return $this->renderError('缺少参数page_url');
}
$page_title = $this->request->post('page_title');
if (empty($page_title)) {
return $this->renderError('缺少参数page_title');
}
$store_id = GoodsModel::$storeId;
$wxConfig = WxappSettingModel::getConfigBasic($store_id);
// 请求api获取短连接
$link_obj = new ShortLink($wxConfig['app_id'], $wxConfig['app_secret']);
$url = $link_obj->shortUrl($page_url, $page_title);
return $this->renderSuccess(['url' => $url]);
}
} }

@ -15,6 +15,7 @@ use app\common\model\Article;
use app\common\model\Store; use app\common\model\Store;
use app\common\model\Agreement; use app\common\model\Agreement;
use app\common\model\UploadFile; use app\common\model\UploadFile;
use app\common\model\Banner;
use app\store\model\server\RecoveryCategory; use app\store\model\server\RecoveryCategory;
use app\store\model\server\ServerRecovery; use app\store\model\server\ServerRecovery;
use app\store\model\server\Server; use app\store\model\server\Server;
@ -23,7 +24,7 @@ use app\store\model\ServerCategory;
// /www/server/php/74/bin/php /server/wwwroot/yanzong/think test // /www/server/php/74/bin/php /server/wwwroot/yanzong/think test
class SyncStoreBasicData extends Command class SyncStoreBasicData extends Command
{ {
const DEFAULT_STORE_ID = 10037; const DEFAULT_STORE_ID = 10048;
protected function configure() protected function configure()
{ {
@ -35,6 +36,7 @@ class SyncStoreBasicData extends Command
$this->addArgument("isSyncRichTextData"); $this->addArgument("isSyncRichTextData");
$this->addArgument("isSyncRecoveryData"); $this->addArgument("isSyncRecoveryData");
$this->addArgument("isSyncServerData"); $this->addArgument("isSyncServerData");
$this->addArgument("isSyncBannerData");
} }
protected function execute(Input $input, Output $output) protected function execute(Input $input, Output $output)
@ -45,6 +47,7 @@ class SyncStoreBasicData extends Command
$isSyncRichTextData = $input->getArgument("isSyncRichTextData"); $isSyncRichTextData = $input->getArgument("isSyncRichTextData");
$isSyncRecoveryData = $input->getArgument("isSyncRecoveryData"); $isSyncRecoveryData = $input->getArgument("isSyncRecoveryData");
$isSyncServerData = $input->getArgument("isSyncServerData"); $isSyncServerData = $input->getArgument("isSyncServerData");
$isSyncBannerData = $input->getArgument("isSyncBannerData");
$where[] = ['is_sync','=', 0]; $where[] = ['is_sync','=', 0];
$where[] = ['is_delete','=', 0]; $where[] = ['is_delete','=', 0];
@ -80,6 +83,9 @@ class SyncStoreBasicData extends Command
if ($isSyncServerData) { if ($isSyncServerData) {
$this->syncServerData($store); $this->syncServerData($store);
} }
if ($isSyncBannerData) {
$this->syncBannerData($store);
}
//Store::where('store_id', $store['store_id'])->update(['is_sync' => 1]); //Store::where('store_id', $store['store_id'])->update(['is_sync' => 1]);
} }
@ -415,5 +421,44 @@ class SyncStoreBasicData extends Command
unset($article); unset($article);
} }
} }
/**
* 同步服务数据
* [syncHelpData description]
* @param [type] $store [description]
* @return [type] [description]
*/
private function syncBannerData($store){
//服务分类数据同步
$articleCategoryList = Banner::where('store_id',self::DEFAULT_STORE_ID)->where('status', 10)->select()->toArray();
if ($articleCategoryList) {
foreach ($articleCategoryList as &$articleCategory) {
$info = Banner::where('store_id', $store['store_id'])->where('original_id', $articleCategory['id'])->find();
if ($info) {
echo $articleCategory['id']."轮播图已存在".PHP_EOL;
continue;
}
$articleCategory['create_time'] = time();
$articleCategory['update_time'] = time();
$articleCategory['original_id'] = $articleCategory['id'];
$articleCategory['store_id'] = $store['store_id'];
unset($articleCategory['id']);
unset($articleCategory['redirect_url']);
//复制图片
$upload_file = Db::name('upload_file')->where('file_id', $articleCategory['image_id'])->find();
if ($upload_file) {
$upload_file['store_id'] = $store['store_id'];
$upload_file['create_time'] = time();
unset($upload_file['file_id']);
$image_id = Db::name('upload_file')->insertGetId($upload_file);
}
//写入维修数据
$articleCategory['image_id'] = $image_id ?? 0;
$ret = Banner::create($articleCategory);
var_dump($ret->id);
}
unset($articleCategory);
}
}
} }

@ -0,0 +1,69 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\enum\goods;
use app\common\enum\EnumBasics;
/**
* 枚举类:商品类型
* Class GoodsType
* @package app\common\enum\goods
*/
class GoodsDeliveryTime extends EnumBasics
{
// 实物商品
const ZERO = 0;
const ONE = 1;
const TWO = 2;
const THREE = 3;
const FOUR = 4;
const FIVE = 4;
const SIX = 5;
/**
* 获取枚举数据
* @return array
*/
public static function data(): array
{
return [
self::ZERO => [
'name' => '24小时',
'value' => self::ZERO,
],
self::ONE => [
'name' => '48小时',
'value' => self::ONE,
],
self::TWO => [
'name' => '72小时',
'value' => self::TWO,
],
self::THREE => [
'name' => '7天内',
'value' => self::THREE,
],
self::FOUR => [
'name' => '15天内',
'value' => self::FOUR,
],
self::FIVE => [
'name' => '30天内',
'value' => self::FIVE,
],
self::SIX => [
'name' => '45天内',
'value' => self::SIX,
]
];
}
}

@ -338,9 +338,9 @@ class Collector extends BaseService
$itemId = $this->getItemId($url, $store); $itemId = $this->getItemId($url, $store);
// 商城采集设置 // 商城采集设置
$config = SettingModel::getItem(SettingEnum::COLLECTOR, $storeId); $config = SettingModel::getItem(SettingEnum::COLLECTOR, $storeId);
if (isset($config['config']['99api']['apiKey']) && !$config['config']['99api']['apiKey']) { // if (isset($config['config']['99api']['apiKey']) && !$config['config']['99api']['apiKey']) {
$config['config']['99api']['apiKey'] = '9271DA7BF37C6F50BED49B7F0ADD49A2'; // $config['config']['99api']['apiKey'] = '9271DA7BF37C6F50BED49B7F0ADD49A2';
} // }
// 请求API查询商品详情 // 请求API查询商品详情
$item = CollectorFacade::store($store) $item = CollectorFacade::store($store)
->setOptions($config['config'][$config['provider']]) ->setOptions($config['config'][$config['provider']])

Loading…
Cancel
Save