- 按 docs/renew-code-comment.md 将 PHP 文件头改为带边框的 Author 注释\n- 注释中的 crmeb.com 替换为 uj345.cn(代码字符串中的外链未改)\n- 新增 docs/renew-code-comment.md 说明 Made-with: Cursor
57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Author: ScottPan Team
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace crmeb\services;
|
|
|
|
use crmeb\interfaces\DeliveryInterface;
|
|
use crmeb\services\delivery\Delivery;
|
|
use crmeb\services\delivery\storage\Dada;
|
|
use crmeb\services\delivery\store\Uupt;
|
|
|
|
/**
|
|
* Class BaseExpress
|
|
* @package crmeb\basic
|
|
*/
|
|
class DeliverySevices
|
|
{
|
|
protected static $delivery = [];
|
|
|
|
const DELIVERY_TYPE_DADA = 1;
|
|
const DELIVERY_TYPE_UU = 2;
|
|
|
|
/**
|
|
* @param int $type
|
|
* @param bool $is_cache
|
|
* @return Delivery|mixed
|
|
*/
|
|
public static function init(int $type = self::DELIVERY_TYPE_DADA, bool $is_cache = false)
|
|
{
|
|
$type = (int)$type;
|
|
|
|
if ($is_cache && isset(self::$delivery['delivery_' . $type]) && self::$delivery['delivery_' . $type]) {
|
|
return self::$delivery['delivery_' . $type];
|
|
}
|
|
$config = [];
|
|
switch ($type) {
|
|
case 1:
|
|
$config = [
|
|
'app_key' => sys_config('dada_app_key'),
|
|
'app_secret' => sys_config('dada_app_sercret'),
|
|
'source_id' => sys_config('dada_source_id'),
|
|
];
|
|
break;
|
|
case 2:
|
|
$config = [
|
|
'app_key' => sys_config('uupt_appkey'),
|
|
'app_id' => sys_config('uupt_app_id'),
|
|
'open_id' => sys_config('uupt_open_id'),
|
|
];
|
|
break;
|
|
}
|
|
return self::$delivery['delivery_' . $type] = new Delivery($type, $config);
|
|
}
|
|
|
|
}
|