175 行
5.7 KiB
PHP
175 行
5.7 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 roleNames()
|
|
{
|
|
return [
|
|
'taster' => trim((string) self::get('partner_role_name_taster', '品酒师')) ?: '品酒师',
|
|
'maker' => trim((string) self::get('partner_role_name_maker', '创客')) ?: '创客',
|
|
'venue' => trim((string) self::get('partner_role_name_venue', '酒道馆')) ?: '酒道馆',
|
|
'county' => trim((string) self::get('partner_role_name_county', '区县代理')) ?: '区县代理',
|
|
'partner' => trim((string) self::get('partner_role_name_partner', '合伙股东')) ?: '合伙股东',
|
|
];
|
|
}
|
|
|
|
public static function rewardTypeText($type)
|
|
{
|
|
$map = self::rewardTypeMap();
|
|
return $map[$type] ?? $type;
|
|
}
|
|
|
|
public static function rewardTypeMap()
|
|
{
|
|
$roles = self::roleNames();
|
|
$maker = $roles['maker'];
|
|
$venue = $roles['venue'];
|
|
$county = $roles['county'];
|
|
|
|
return [
|
|
'push3' => '推荐开拓奖',
|
|
'maker_diff' => $maker . '进阶奖',
|
|
'maker_peer' => $maker . '协同奖',
|
|
'maker_overtaken' => $maker . '卓越奖',
|
|
'team_venue' => $venue . '运营奖',
|
|
'team_county' => $county . '统筹奖',
|
|
'venue_peer' => $venue . '协同奖',
|
|
'county_peer' => $county . '协同奖',
|
|
'venue_share' => $venue . '加权奖励',
|
|
'county_share' => $county . '加权奖励',
|
|
'madow_share' => '每日贡献马豆',
|
|
'voucher_grant' => '消费补贴发放',
|
|
'voucher_release' => '消费补贴到账',
|
|
'voucher_consume' => '消费券抵扣',
|
|
'voucher_consume_refund' => '消费券退款退还',
|
|
];
|
|
}
|
|
|
|
public static function skipReasonText($code, $forUser = false)
|
|
{
|
|
$roles = self::roleNames();
|
|
$maker = $roles['maker'];
|
|
$venue = $roles['venue'];
|
|
$county = $roles['county'];
|
|
|
|
$inner = [
|
|
'no_parent' => '无推荐上级',
|
|
'self_buy' => '本人自购',
|
|
'inactive_30d' => '受益人 30 日无自购',
|
|
'not_maker' => '不是' . $maker . '身份',
|
|
'not_venue' => '不是' . $venue . '身份',
|
|
'not_county' => '不是' . $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'];
|
|
}
|
|
}
|