文件
Henglianshutong/addons/shopro/service/partner/PartnerConfig.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'];
}
}