diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index 2a093948..5f3d514e 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -15,10 +15,8 @@ namespace app\api\controller; use app\api\model\{Goods as GoodsModel, Store as StoreModel}; use app\api\model\Region; 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\UploadFile as UploadFileModel; -use app\common\model\wxapp\Setting as WxappSettingModel; use app\common\service\qrcode\Goods as GoodsPoster; use cores\exception\BaseException; use think\db\exception\DbException; @@ -99,6 +97,7 @@ class Goods extends Controller 'state' => "无货", 'goods_name' => $goods['goods_name'], 'goods_id' => $goods['goods_id'], + 'promise_info' => "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']] ?? "72小时")."内发货", ]; $return[] = $data; continue; @@ -112,6 +111,7 @@ class Goods extends Controller $data = $suning->shoppingCartPrice([$goods->toArray()], $city->sn_code, $district->sn_code); $data['goods_name'] = $goods['goods_name']; $data['goods_id'] = $goods['goods_id']; + $data['promise_info'] = "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']] ?? "72小时")."内发货"; break; case 'jd': case 'jd1': @@ -134,6 +134,7 @@ class Goods extends Controller 'state' => $res, 'goods_name' => $goods['goods_name'], 'goods_id' => $goods['goods_id'], + 'promise_info' => $ret['promiseInfo'] ?? "预计72小时内发货", ]; break; default: @@ -144,6 +145,7 @@ class Goods extends Controller 'state' => $res, 'goods_name' => $goods['goods_name'], 'goods_id' => $goods['goods_id'], + 'promise_info' => "预计".(GoodsDeliveryTime::data()[$goods['delivery_time']] ?? "72小时")."内发货", ]; break; @@ -385,22 +387,5 @@ class Goods extends Controller 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]); - } } diff --git a/app/command/SyncStoreBasicData.php b/app/command/SyncStoreBasicData.php index 68684f86..35079656 100644 --- a/app/command/SyncStoreBasicData.php +++ b/app/command/SyncStoreBasicData.php @@ -15,6 +15,7 @@ use app\common\model\Article; use app\common\model\Store; use app\common\model\Agreement; use app\common\model\UploadFile; +use app\common\model\Banner; use app\store\model\server\RecoveryCategory; use app\store\model\server\ServerRecovery; 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 class SyncStoreBasicData extends Command { - const DEFAULT_STORE_ID = 10037; + const DEFAULT_STORE_ID = 10048; protected function configure() { @@ -35,6 +36,7 @@ class SyncStoreBasicData extends Command $this->addArgument("isSyncRichTextData"); $this->addArgument("isSyncRecoveryData"); $this->addArgument("isSyncServerData"); + $this->addArgument("isSyncBannerData"); } protected function execute(Input $input, Output $output) @@ -45,6 +47,7 @@ class SyncStoreBasicData extends Command $isSyncRichTextData = $input->getArgument("isSyncRichTextData"); $isSyncRecoveryData = $input->getArgument("isSyncRecoveryData"); $isSyncServerData = $input->getArgument("isSyncServerData"); + $isSyncBannerData = $input->getArgument("isSyncBannerData"); $where[] = ['is_sync','=', 0]; $where[] = ['is_delete','=', 0]; @@ -80,6 +83,9 @@ class SyncStoreBasicData extends Command if ($isSyncServerData) { $this->syncServerData($store); } + if ($isSyncBannerData) { + $this->syncBannerData($store); + } //Store::where('store_id', $store['store_id'])->update(['is_sync' => 1]); } @@ -415,5 +421,44 @@ class SyncStoreBasicData extends Command 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); + } + + } } diff --git a/app/common/enum/goods/GoodsDeliveryTime.php b/app/common/enum/goods/GoodsDeliveryTime.php new file mode 100644 index 00000000..fbe3a134 --- /dev/null +++ b/app/common/enum/goods/GoodsDeliveryTime.php @@ -0,0 +1,69 @@ + +// +---------------------------------------------------------------------- +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, + ] + ]; + } +} \ No newline at end of file diff --git a/app/job/service/goods/Collector.php b/app/job/service/goods/Collector.php index 6ba418e5..6eebed05 100644 --- a/app/job/service/goods/Collector.php +++ b/app/job/service/goods/Collector.php @@ -338,9 +338,9 @@ class Collector extends BaseService $itemId = $this->getItemId($url, $store); // 商城采集设置 $config = SettingModel::getItem(SettingEnum::COLLECTOR, $storeId); - if (isset($config['config']['99api']['apiKey']) && !$config['config']['99api']['apiKey']) { - $config['config']['99api']['apiKey'] = '9271DA7BF37C6F50BED49B7F0ADD49A2'; - } + // if (isset($config['config']['99api']['apiKey']) && !$config['config']['99api']['apiKey']) { + // $config['config']['99api']['apiKey'] = '9271DA7BF37C6F50BED49B7F0ADD49A2'; + // } // 请求API查询商品详情 $item = CollectorFacade::store($store) ->setOptions($config['config'][$config['provider']])