1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright © Getnet. All rights reserved. |
4
|
|
|
* |
5
|
|
|
* @author Bruno Elisei <[email protected]> |
6
|
|
|
* See LICENSE for license details. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Getnet\SplitExampleMagento\Helper; |
10
|
|
|
|
11
|
|
|
use Getnet\SplitExampleMagento\Model\Config; |
12
|
|
|
use Magento\Store\Model\Store; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Sub Seller Helper. |
16
|
|
|
*/ |
17
|
|
|
class Data extends \Magento\Framework\App\Helper\AbstractHelper |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var Config |
21
|
|
|
*/ |
22
|
|
|
protected $configSplit; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Constructor. |
26
|
|
|
* |
27
|
|
|
* @param Config $configSplit |
28
|
|
|
*/ |
29
|
|
|
public function __construct( |
30
|
|
|
Config $configSplit |
31
|
|
|
) { |
32
|
|
|
$this->configSplit = $configSplit; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Get List Commissions Formated. |
37
|
|
|
* |
38
|
|
|
* @param null|string|bool|int|Store $store |
39
|
|
|
* |
40
|
|
|
* @return array |
41
|
|
|
*/ |
42
|
|
|
public function getSplitCommissions($store = null) |
43
|
|
|
{ |
44
|
|
|
$list = $this->configSplit->getSplitCommissions($store); |
45
|
|
|
$listCommissions = []; |
46
|
|
|
|
47
|
|
|
foreach ($list as $commission) { |
48
|
|
|
$sellerId = $commission['sub_seller_id']; |
49
|
|
|
|
50
|
|
|
$listCommissions[$sellerId] = [ |
51
|
|
|
'commission_percentage' => $commission['commission_percentage'], |
52
|
|
|
'include_freight' => ($commission['include_freight'] === 'full') ? true : false, |
53
|
|
|
'include_interest' => ($commission['include_interest'] === 'full') ? true : false, |
54
|
|
|
]; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return $listCommissions; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Get Split Commission By Sub Seller Id. |
62
|
|
|
* |
63
|
|
|
* @param string $subSellerId |
64
|
|
|
* @param null|string|bool|int|Store $store |
65
|
|
|
* |
66
|
|
|
* @return null|array |
67
|
|
|
*/ |
68
|
|
|
public function getSplitCommissionsBySubSellerId(string $subSellerId, $store = null): ?array |
69
|
|
|
{ |
70
|
|
|
$commission = $this->getSplitCommissions($store); |
71
|
|
|
|
72
|
|
|
if (!isset($commission[$subSellerId])) { |
73
|
|
|
return $commission['any']; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
return $commission[$subSellerId]; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Get Guarantor Name. |
81
|
|
|
* |
82
|
|
|
* @param null|string|bool|int|Store $store |
83
|
|
|
* |
84
|
|
|
* @return null|string |
85
|
|
|
*/ |
86
|
|
|
public function getAdditionalGuarantorName($store = null): ?string |
87
|
|
|
{ |
88
|
|
|
return $this->configSplit->getGuarantorName($store); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Get Guarantor Number. |
93
|
|
|
* |
94
|
|
|
* @param null|string|bool|int|Store $store |
95
|
|
|
* |
96
|
|
|
* @return null|string |
97
|
|
|
*/ |
98
|
|
|
public function getAdditionalGuarantorNumber($store = null): ?string |
99
|
|
|
{ |
100
|
|
|
return $this->configSplit->getGuarantorDocument($store); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Get Type Release. |
105
|
|
|
* |
106
|
|
|
* @param null|string|bool|int|Store $store |
107
|
|
|
* |
108
|
|
|
* @return null|string |
109
|
|
|
*/ |
110
|
|
|
public function getTypeRelease($store = null): ?string |
111
|
|
|
{ |
112
|
|
|
return $this->configSplit->getTypeRelease($store); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Get Days of Release. |
117
|
|
|
* |
118
|
|
|
* @param null|string|bool|int|Store $store |
119
|
|
|
* |
120
|
|
|
* @return null|string |
121
|
|
|
*/ |
122
|
|
|
public function getDaysOfRelease($store = null): ?string |
123
|
|
|
{ |
124
|
|
|
return $this->configSplit->getCronDays($store); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|