目前已有一号通、99api复制商品扩展
namespace crmeb\services\copyproduct;use crmeb\basic\BaseManager;use crmeb\services\AccessTokenServeService;use think\facade\Config;use think\Container;/*** Class Product* @package crmeb\services\copyproduct* @mixin \crmeb\services\copyproduct\CopyProduct*/class CopyProduct extends BaseManager{/*** 空间名* @var string*/protected $namespace = '\crmeb\services\copyproduct\storage\';/*** 默认驱动* @return mixed*/protected function getDefaultDriver(){return Config::get('product.default', 'copy');}/*** 获取类的实例* @param $class* @return mixed|void*/protected function invokeClass($class){if (!class_exists($class)) {throw new \RuntimeException('class not exists: ' . $class);}$this->getConfigFile();if (!$this->config) {$this->config = Config::get($this->configFile . '.stores.' . $this->name, []);}$handleAccessToken = new AccessTokenServeService($this->config['account'] ?? '', $this->config['secret'] ?? '');$handle = Container::getInstance()->invokeClass($class, [$this->name, $handleAccessToken, $this->configFile]);$this->config = [];return $handle;}}
invokeClass 里面的逻辑针对获取请求之前的逻辑做处理;AccessTokenServeService里面主要获取请求header,例如token之类的参数
默认使用一号通复制商品扩展
use crmeb\services\copyproduct\CopyProduct;$copy = new CopyProduct();//or$copy = app()->make(CopyProduct::class);//复制商品$goodInfo = $copy->goods($url, $options = []);var_dump($goodInfo);
使用99api复制商品扩展
use crmeb\services\copyproduct\CopyProduct;$copy = new CopyProduct('copy99api');//or$copy = app()->make(CopyProduct::class,['copy99api']);//复制商品$goodInfo = $copy->goods($url, $options = []);var_dump($goodInfo);
Copyright 2014-2025 //m.sbmmt.com/ All Rights Reserved | php.cn | 湘ICP备2023035733号