154 行
4.8 KiB
PHP
154 行
4.8 KiB
PHP
<?php
|
|
|
|
namespace addons\shopro\service\partner;
|
|
|
|
/**
|
|
* 合伙股东配置读取
|
|
*/
|
|
class PartnerConfig
|
|
{
|
|
public static function get($key, $default = null)
|
|
{
|
|
$code = strpos($key, 'shop.commission.') === 0 ? $key : 'shop.commission.' . $key;
|
|
if (!function_exists('sheep_config')) {
|
|
$helper = defined('ROOT_PATH') ? (ROOT_PATH . 'addons/shopro/helper/helper.php') : (__DIR__ . '/../../helper/helper.php');
|
|
if (file_exists($helper)) {
|
|
require_once $helper;
|
|
}
|
|
}
|
|
$value = function_exists('sheep_config') ? sheep_config($code) : null;
|
|
if ($value === null || $value === '') {
|
|
return $default;
|
|
}
|
|
return $value;
|
|
}
|
|
|
|
public static function isPartnerMode()
|
|
{
|
|
return (bool) self::get('partner_mode', 0);
|
|
}
|
|
|
|
public static function isEnabled()
|
|
{
|
|
$enable = self::get('partner_enable', 1);
|
|
return $enable === null ? true : (bool) $enable;
|
|
}
|
|
|
|
public static function activeDays()
|
|
{
|
|
$days = intval(self::get('partner_active_days', 30));
|
|
return $days > 0 ? $days : 30;
|
|
}
|
|
|
|
public static function chainMaxDepth()
|
|
{
|
|
$depth = intval(self::get('partner_chain_max_depth', 50));
|
|
return $depth > 0 ? $depth : 50;
|
|
}
|
|
|
|
public static function push3Amounts()
|
|
{
|
|
$amounts = self::get('partner_push3_amounts', [398, 400, 600]);
|
|
if (!is_array($amounts) || count($amounts) < 3) {
|
|
return [398, 400, 600];
|
|
}
|
|
return array_map('floatval', array_values($amounts));
|
|
}
|
|
|
|
public static function makerBonus()
|
|
{
|
|
$bonus = self::get('partner_maker_bonus', [2 => 20, 3 => 40, 4 => 60, 5 => 80, 6 => 100, 7 => 120]);
|
|
if (!is_array($bonus)) {
|
|
return [2 => 20, 3 => 40, 4 => 60, 5 => 80, 6 => 100, 7 => 120];
|
|
}
|
|
$map = [];
|
|
foreach ($bonus as $level => $amount) {
|
|
$map[intval($level)] = floatval($amount);
|
|
}
|
|
return $map;
|
|
}
|
|
|
|
public static function rewardTypeText($type)
|
|
{
|
|
$map = self::rewardTypeMap();
|
|
return $map[$type] ?? $type;
|
|
}
|
|
|
|
public static function rewardTypeMap()
|
|
{
|
|
return [
|
|
'push3' => '推三返一',
|
|
'maker_diff' => '创客极差奖',
|
|
'maker_peer' => '创客平级奖',
|
|
'maker_overtaken' => '创客超越奖',
|
|
'team_venue' => '酒道馆团队奖',
|
|
'team_county' => '区县团队奖',
|
|
'venue_peer' => '酒道馆平级奖',
|
|
'county_peer' => '区县平级奖',
|
|
'venue_share' => '酒道馆平台均分',
|
|
'county_share' => '区县平台均分',
|
|
'madow_share' => '每日分红马豆',
|
|
'voucher_grant' => '兑换券发放',
|
|
'voucher_release' => '兑换券释放',
|
|
'voucher_consume' => '兑换券消费抵扣',
|
|
'voucher_consume_refund' => '兑换券退款退还',
|
|
];
|
|
}
|
|
|
|
public static function skipReasonText($code, $forUser = false)
|
|
{
|
|
$inner = [
|
|
'no_parent' => '无直推上级',
|
|
'self_buy' => '自购',
|
|
'inactive_30d' => '受益人 30 日无自购',
|
|
'not_maker' => '不是创客',
|
|
'not_venue' => '不是酒道馆',
|
|
'not_county' => '不是区县代理',
|
|
'cap_not_higher' => '等级未超过水位',
|
|
'already_settled' => '幂等跳过',
|
|
'partner_goods_off' => '商品未参与',
|
|
'partner_off' => '结算未开启',
|
|
];
|
|
$user = [
|
|
'no_parent' => '暂无推荐人,不产生推三返一',
|
|
'self_buy' => '自己下单不产生推三返一',
|
|
'inactive_30d' => '需 30 日内有本人订单才能领取',
|
|
'not_maker' => '',
|
|
'not_venue' => '',
|
|
'not_county' => '',
|
|
'cap_not_higher' => '平级不发极差,走平级奖',
|
|
'already_settled' => '',
|
|
'partner_goods_off' => '',
|
|
'partner_off' => '',
|
|
];
|
|
if ($forUser) {
|
|
return $user[$code] ?? '';
|
|
}
|
|
return $inner[$code] ?? $code;
|
|
}
|
|
|
|
public static function statusText($status)
|
|
{
|
|
$map = [
|
|
0 => '待入账',
|
|
1 => '已入账',
|
|
-1 => '已取消',
|
|
-2 => '已退回',
|
|
];
|
|
return $map[intval($status)] ?? '';
|
|
}
|
|
|
|
public static function instantTypes()
|
|
{
|
|
return [
|
|
'push3', 'maker_diff', 'maker_peer', 'maker_overtaken',
|
|
'team_venue', 'team_county', 'venue_peer', 'county_peer',
|
|
];
|
|
}
|
|
|
|
public static function dailyTypes()
|
|
{
|
|
return ['venue_share', 'county_share', 'madow_share', 'voucher_release'];
|
|
}
|
|
}
|