|
|
<?php
|
|
|
|
|
|
class DsAppTool {
|
|
|
|
|
|
public static function getMenuList($isShowAutoPurchaseMenu) {
|
|
|
$menuList = [
|
|
|
array(
|
|
|
'name' => '1688铺货',
|
|
|
'url' => Zc::url(RouteConst::moveBatchDsCopy, '', false, AppConst::getDuoDuoCloudHost(true, true)),
|
|
|
'selectedRoute' => array(
|
|
|
RouteConst::moveBatchDsCopy,
|
|
|
),
|
|
|
),
|
|
|
array(
|
|
|
'name' => '铺货日志',
|
|
|
'url' => Zc::url(RouteConst::moveBatchDsHistory, '', false, AppConst::getDuoDuoCloudHost(true, true)),
|
|
|
'selectedRoute' => array(
|
|
|
RouteConst::moveBatchDsHistory,
|
|
|
),
|
|
|
),
|
|
|
array(
|
|
|
'name' => '分销商品',
|
|
|
'url' => Zc::url(RouteConst::goodsDsGoodsDs, '', false, AppConst::getDuoDuoCloudHost(true, true)),
|
|
|
'selectedRoute' => array(
|
|
|
RouteConst::goodsDsGoodsDs,
|
|
|
),
|
|
|
),
|
|
|
array(
|
|
|
'name' => '非分销商品',
|
|
|
'url' => Zc::url(RouteConst::goodsDsGoodsDsSource, '', false, AppConst::getDuoDuoCloudHost(true, true)),
|
|
|
'selectedRoute' => array(
|
|
|
RouteConst::goodsDsGoodsDsSource,
|
|
|
),
|
|
|
),
|
|
|
[
|
|
|
'name' => '分销订单',
|
|
|
'url' => Zc::url(RouteConst::orderStockUpDistributionOrder, ['purchaseOrderTab' => 'wait_purchase'], false, AppConst::getDuoDuoCloudHost(true, false)),
|
|
|
'selectedRoute' => [
|
|
|
RouteConst::orderStockUpDistributionOrder,
|
|
|
],
|
|
|
'extKey' => 'purchaseOrderTab',
|
|
|
'extValue' => 'wait_purchase',
|
|
|
],
|
|
|
[
|
|
|
'name' => '发货历史',
|
|
|
'url' => Zc::url(RouteConst::orderStockUpDsOutstorageLog),
|
|
|
'selectedRoute' => [
|
|
|
RouteConst::orderStockUpDsOutstorageLog,
|
|
|
]
|
|
|
],
|
|
|
[
|
|
|
'name' => '自动售后',
|
|
|
'url' => Zc::url(RouteConst::orderStockUpDistributionAutoAfterSales),
|
|
|
'selectedRoute' => [
|
|
|
RouteConst::orderStockUpDistributionAutoAfterSales,
|
|
|
]
|
|
|
],
|
|
|
];
|
|
|
|
|
|
if ($isShowAutoPurchaseMenu) {
|
|
|
$menuList[] = [
|
|
|
'name' => '自动采购',
|
|
|
'url' => Zc::url(RouteConst::orderStockUpDistributionAutoPurchase, null, false, AppConst::getDuoDuoCloudHost(true, false)),
|
|
|
'selectedRoute' => [
|
|
|
RouteConst::orderStockUpDistributionAutoPurchase,
|
|
|
],
|
|
|
];
|
|
|
}
|
|
|
|
|
|
return $menuList;
|
|
|
}
|
|
|
|
|
|
public static function rebuildDsAutoPurchaseFailReason($reason, $memberAuthUrl = null) {
|
|
|
$newReason = $reason;
|
|
|
|
|
|
if (stripos($reason, 'authorized') !== false) {
|
|
|
$newReason = sprintf('【%s】授权已过期,请重新授权', DsConst::getDsAppChineseName());
|
|
|
if ($memberAuthUrl) {
|
|
|
$newReason .= sprintf(',<a href="%s" target="_blank" class="btn btn-sm btn-warning"><b>立即授权</b></a>', $memberAuthUrl);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return $newReason;
|
|
|
}
|
|
|
|
|
|
public static function getDsApiFailReason($reason, $memberAuthUrl) {
|
|
|
$newReason = $reason;
|
|
|
|
|
|
if (stripos($reason, 'authorized') !== false) {
|
|
|
$newReason = sprintf('【妙手分销】授权已过期,请重新授权,<a href="%s" target="_blank" class="btn btn-sm btn-warning"><b>立即授权</b></a>', $memberAuthUrl);
|
|
|
}
|
|
|
|
|
|
if (stripos($reason, '已下架') !== false) {
|
|
|
$newReason = '1688商品已下架,请更换货源后采购';
|
|
|
}
|
|
|
|
|
|
if (stripos($reason, '已删除') !== false) {
|
|
|
$newReason = '1688商品已删除,请更换货源后采购';
|
|
|
}
|
|
|
|
|
|
return $newReason;
|
|
|
}
|
|
|
|
|
|
public static function rebuildPddApiFailReason($reason) {
|
|
|
$newReason = $reason;
|
|
|
|
|
|
if (preg_match('/(授权已失效|授权已过期)/iU', $reason)) {
|
|
|
$authUrl = PddOAuthUtil::buildPddAuthUrl();
|
|
|
$newReason = sprintf('%s,请重新授权,<a href="%s" target="_blank" class="btn btn-sm btn-warning"><b>立即授权</b></a>', $reason, $authUrl);
|
|
|
}
|
|
|
|
|
|
return $newReason;
|
|
|
}
|
|
|
|
|
|
public static function rebuildCheckDsAppAuthExpireRet($ret, $loginUserId) {
|
|
|
$ret['loginUserId'] = $loginUserId;
|
|
|
$memberAuthUrl = $ret['memberAuthUrl'];
|
|
|
|
|
|
foreach ($ret['userIdAndCheckRetMap'] as $userId => &$checkRet) {
|
|
|
if (CommonTool::isSuccessRet($checkRet)) {
|
|
|
continue;
|
|
|
}
|
|
|
if ($checkRet['code'] == DsConst::authExpireTypeOrderExpire) {
|
|
|
$checkRet['solution'] = sprintf('1688妙手分销已过期,为了避免影响正常发货和使用,请<a target="_blank" href="%s">重新订购</a>', AppConst::dsAppServiceMarketUrl);
|
|
|
$checkRet['tip'] = sprintf('1688妙手分销订购过期,为了避免影响正常发货和使用,请<a target="_blank" href="%s">先去订购</a>', AppConst::dsAppServiceMarketUrl);
|
|
|
} elseif ($checkRet['code'] == DsConst::authExpireTypeAuthExpire) {
|
|
|
$checkRet['solution'] = sprintf('1688妙手分销授权失效,为了避免影响正常发货和使用,请<a target="_blank" href="%s">重新授权</a>', $memberAuthUrl);
|
|
|
$checkRet['tip'] = sprintf('1688妙手分销授权失效,为了避免影响正常发货和使用,请<a target="_blank" href="%s">重新授权</a>', $memberAuthUrl);
|
|
|
} else {
|
|
|
$checkRet['solution'] = $checkRet['reason'];
|
|
|
}
|
|
|
}
|
|
|
unset($checkRet);
|
|
|
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
public static function getHelpLink($key) {
|
|
|
$map = [
|
|
|
AppConst::appMsPddOd => [
|
|
|
'dsEncryptOrder' => 'https://pdd-od.chengji-inc.com/front/help/index?articleId=31',
|
|
|
],
|
|
|
];
|
|
|
$appName = Zc::C('appName');
|
|
|
return $key ? $map[$appName][$key] : $map[$appName];
|
|
|
}
|
|
|
|
|
|
public static function checkApiVersion($version, $errorCode = ErrorCodeConst::bizDsApiUpdate, $lastVersion = 1.0) {
|
|
|
if ($version == $lastVersion) {
|
|
|
return CommonTool::successResult();
|
|
|
}
|
|
|
return CommonTool::failCodeResult($errorCode, '接口升级,请强制刷新页面后再操作【Windows系统:ctrl + F5】【IOS系统:command + R】');
|
|
|
}
|
|
|
|
|
|
} |