/var/www/hkosl.com/littleark/webadmin/models/Supplier.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<?php

    
use Illuminate\Database\Capsule\Manager as DB;
    use 
Carbon\Carbon as Carbon;

    class 
Supplier extends BaseModel
    
{
        protected 
$table "supplier";

        
// default values
        
protected $attributes = [
            
// 'platform_commission_value' => '5',
            
'currency_code'   => 'CNY',
            
'currency_rate'   => '1',
            
'settlement_type' => 'MERCHANT',
            
'billing_method'  => 'T+n',
            
'billing_value'   => 7,
        ];

        public function 
orderDiscounts()
        {
            return 
$this->hasMany('OrderDiscount');
        }

        public function 
currency()
        {
            return 
$this->belongsTo('Currency''currency_code''iso_code');
        }

        public function 
proProducts()
        {
            return 
$this->hasMany('ProProduct');
        }

        public function 
proProductSkus()
        {
            return 
$this->hasMany('ProProductSku');
        }

        public function 
payesePaymentSubmits()
        {
            return 
$this->hasMany('PayeasePaymentSubmit');
        }

        public function 
payeasePaymentDtls()
        {
            return 
$this->hasMany('PayeasePaymentDtl');
        }

        public function 
active_proProducts()
        {
            return 
$this->hasMany('ProProduct')->where('status'1)->get();
        }

        public function 
agent()
        {
            return 
$this->belongsTo('Agent');
        }

        public function 
active_product_count()
        {
            return 
count($this->active_proProducts());
        }

        public function 
can_active_product()
        {
            if (
$this->active_product_quota === '' || $this->active_product_quota === null) {
                return 
true;
            }
            return 
$this->active_product_quota $this->active_product_count();
        }

        
/**
         * get the net amount after commission deduction
         *
         * @param  float $ori_total_amount original total
         *
         * @return float                    amount after deduct commission
         */
        
public function deductCommission($ori_total_amount 0)
        {
            if (
$this->platform_commission_method == "Percent") {
                
$amount round($ori_total_amount * (100 $this->platform_commission_value) / 100$_SESSION['platform_currency_precision']);
            } else {
                
//fixed
                
$amount round($ori_total_amount $this->platform_commission_value$_SESSION['platform_currency_precision']);
            }
            return 
$amount;
        }

        public function 
getSettlementSubmerchantNumber()
        {
            switch (
$this->settlement_type) {
                case 
'PLATFORM':
                    return 
false;
                    break;

                case 
'AGENT':
                    if (
$this->agent) {
                        return 
$this->agent->payease_sub_merchant_number;
                    }
                    break;

                case 
'MERCHANT':
                    return 
$this->payease_sub_merchant_number;
                    break;

                default:
                    break;
            }
        }

        public function 
getSettlementMerchantId()
        {
            switch (
$this->settlement_type) {
                case 
'PLATFORM':
                    return 
false;
                    break;

                case 
'AGENT':
                    if (
$this->agent) {
                        return 
$this->agent->payease_account_code;
                    }
                    break;

                case 
'MERCHANT':
                    return 
$this->payease_account_code;
                    break;

                default:
                    break;
            }
        }

        public function 
getSettlementPaymentGateway()
        {
            switch (
$this->currency_code) {
                case 
'IDR':
                    return 
'FINPAY';

                case 
'CNY':
                default:
                    return 
'PAYEASE';
            }
        }

        public static function 
application_type($type)
        {
            
$type_list = array("CHINESE_MERCHANT" => "Chinese Merchant""OVERSEAS_MERCHANT" => "Overseas Merchant");

            if (!empty(
$type)) {
                return 
$type_list[$type];
            } else {
                return 
$type_list;
            }
        }

        public static function 
registration_field($type$form_num 1$step 1)
        {
            
$langcode $_SESSION["langcode"];

            
//country list
            
$country_list         Country::where("deleted""0")->orderBy("name_en""ASC")->get();
            
$country_enable_value = array();
            foreach (
$country_list as $row) {
                
$country_enable_value[$row["id"]] = $row["name_" $langcode];
            }

            
//currency list
            
$currency_list         Currency::whereRaw("deleted = ? and (platform = ? or platform like ?)", array(0"All"'%' $_SESSION["application_platform"] . '%'))->orderBy("name_en""ASC")->get();
            
$currency_enable_value = array();
            foreach (
$currency_list as $row) {
                
$currency_enable_value[$row["id"]] = $row["iso_code"];
            }

            
//email language
            
$email_langcode_enable_value = array("en" => "English""sc" => "Simplified Chinese");
            
$platform_registration       MasterTypeCode::where("typeid""PLATFORM_FOR_REGISTRATION")->where("code"$_SESSION["application_platform"])->where("deleted""0")->first();
            if (!empty(
$email_langcode_enable_value)) {
                
$email_langcode_enable_value[$platform_registration["ext1"]] = $platform_registration["name_en"];
            }

            
$application_status_enable_value = array("NEW" => "New""SUBMITTED" => "Submitted""PRE_APPROVED" => "Pre-Approved""PROCESSING" => "Processing""APPROVED" => "Approved""COMPLETED" => "Completed""REJECTED" => "Rejected""CANCEL" => "Cancel");

            if (
$form_num == && ($type == "CHINESE_MERCHANT" || $type == "OVERSEAS_MERCHANT")) {
                
$form_list = array(
                    
//separate
                    
"merchant_information"            => array("type" => "legend""label" => "Merchant Information""step" => 1),
                    
"name_en"                         => array("type" => "text""label" => "Merchant Name""required" => "required""disabled" => """class" => """value" => """enable_value" => array(), "step" => 1),
                    
"payease_bank_name"               => array("type" => "text""label" => "Bank Name""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 1),
                    
"payease_bank_client_name"        => array("type" => "text""label" => "Account Name""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 1),
                    
"payease_bank_client_accountcode" => array("type" => "text""label" => "Account No.""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 1),
                    
"product_desc"                    => array("type" => "textarea""label" => "Product Description""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 1),

                    
//separate
                    
"contact_information"             => array("type" => "legend""label" => "Contact Information""step" => 2),

                    
"business_contact_title"          => array("type" => "text""label" => "Business Contact - Title""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"business_contact_name"           => array("type" => "text""label" => "Business Contact - Name""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"business_contact_email"      => array("type" => "text""label" => "Business Contact - Eamil""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"business_contact_telephone"      => array("type" => "text""label" => "Business Contact - Telephone""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"financial_contact_title"         => array("type" => "text""label" => "Financial Contact - Title""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"financial_contact_name"          => array("type" => "text""label" => "Financial Contact - Name""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"financial_contact_email"          => array("type" => "text""label" => "Financial Contact - Email""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"financial_contact_telephone"     => array("type" => "text""label" => "Financial Contact - Telephone""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"technical_contact_title"         => array("type" => "text""label" => "Technical Contact - Title""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"technical_contact_name"          => array("type" => "text""label" => "Technical Contact - Name""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"technical_contact_email"          => array("type" => "text""label" => "Technical Contact - Email""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"technical_contact_telephone"     => array("type" => "text""label" => "Technical Contact - Telephone""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"company_telephone"               => array("type" => "text""label" => "Company Telephone""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"refund_confirmation_telephone"   => array("type" => "text""label" => "Cellphone Number for Refund Confirmation""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"company_email"                   => array("type" => "text""label" => "Company Email""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"receive_order_email"             => array("type" => "text""label" => "Order Receiving Email""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"email_langcode"                  => array("type" => "select""label" => "Email Language""required" => """disabled" => """class" => "select2""value" => """enable_value" => $email_langcode_enable_value"step" => 2),

                    
//separate
                    
"customs_declaration_information" => array("type" => "legend""label" => "Customs Declaration Information""step" => 3),

                    
"ebccode"                                                          => array("type" => "text""label" => "Customs Registration Number""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 3),
                    
"ebcname"                                                          => array("type" => "text""label" => "Company Name Registered at Customs""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 3),
                    
"case_number"                                                      => array("type" => "text""label" => "Customs Case Number""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 3),

                    
//separate
                    //"initial_login"                                                    => array("type" => "legend", "label" => "Information on Initial Login to Merchant Management Platform", "step" => 4),
                    //"platform_url"                                                     => array("type" => "text", "label" => "Merchant Management Platform", "required" => "", "disabled" => "disabled", "value" => "http://" . strtolower($_SESSION["application_platform"]) . ".silkroadebelt.com/webadmin/", "enable_value" => array(), "step" => 4),

                    //separate
                    
"settlement_info"                                                  => array("type" => "legend""label" => "Settlement Information""step" => 4),
                    
"currency_code"                                                    => array("type" => "select""label" => "Settlement Currency""required" => """disabled" => """class" => "select2""value" => """enable_value" => $currency_enable_value"step" => 4),


                    
//separate
                    
"business_license"                                                 => array("type" => "legend""label" => "Business License""step" => 5),
                    
"business_license_no"                                              => array("type" => "text""label" => "No.""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 5),
                    
"business_license_effective_period"                                => array("type" => "text""label" => "Effective Period""required" => """disabled" => """class" => "datepicker""value" => """enable_value" => array(), "step" => 5),

                    
//separate
                    
"legal_representative"                                             => array("type" => "legend""label" => "Legal Representative""step" => 6),
                    
"legal_representative_name"                                        => array("type" => "text""label" => "Name""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 6),
                    
"legal_representative_identity_certification_document_type_number" => array("type" => "text""label" => "Identity Certification Document Type and Number""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 6),
                    
"legal_representative_identity_certification_effective_period"     => array("type" => "text""label" => "Effective Period""required" => """disabled" => """class" => "datepicker""value" => """enable_value" => array(), "step" => 6),

                    
//separate
                    
"authorized_agent"                                                 => array("type" => "legend""label" => "Authorized Agent""step" => 7),
                    
"authorized_agent_name"                                            => array("type" => "text""label" => "Name""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 7),
                    
"authorized_agent_identity_certification_document_type_number"     => array("type" => "text""label" => "Identity Certification Document Type and Number""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 7),
                    
"authorized_agent_identity_certification_effective_period"         => array("type" => "text""label" => "Effective Period""required" => """disabled" => """class" => "datepicker""value" => """enable_value" => array(), "step" => 7),

                    
//separate
                    
"business_scope"                                                   => array("type" => "legend""label" => "Business Scope""step" => 8),
                    
"business_scope_desc"                                              => array("type" => "textarea""label" => "Description""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 8),

                    
//separate
                    
"controlling_shareholder_or_actual_controller"                     => array("type" => "legend""label" => "Controlling Shareholder or Actual Controller""step" => 9),
                    
"controlling_shareholder_or_actual_controller_desc"                => array("type" => "textarea""label" => "Description""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 9),
                );
            } else if (
$form_num == && $type == "OVERSEAS_MERCHANT") {
                
$form_list = array(
                    
"merchant_information"            => array("type" => "legend""label" => "Merchant Information (Overseas)""step" => 1),
                    
"name_en"                         => array("type" => "text""label" => "Merchant Name""required" => "required""disabled" => """class" => """value" => """enable_value" => array(), "step" => 1),
                    
"platform_commission_value"       => array("type" => "text""label" => "Transfer Ratio""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 1),
                    
/*"billing_method"                  => array("type" => "radio", "label" => "Settlement Method", "required" => "", "disabled" => "", "class" => "", "value" => "", "enable_value" => array("AMOUNT" => "Total Amount", "T+n" => "T+n")),
                    "billing_value"                   => array("type" => "text", "label" => "Settlement Value", "required" => "", "disabled" => "", "class" => "", "value" => "", "enable_value" => array()),
                    "payease_account_code"            => array("type" => "text", "label" => "Merchant ID (PayEase)", "required" => "", "disabled" => "", "class" => "", "value" => "", "enable_value" => array()),*/

                    //separate
                    
"account_info"                    => array("type" => "legend""label" => "Account Information (Overseas)""step" => 2),
                    
"swift_code"                      => array("type" => "text""label" => "Swift Code""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"payease_bank_name"               => array("type" => "text""label" => "Bank Name""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"payease_bank_client_name"        => array("type" => "text""label" => "Account Name""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"payease_bank_client_accountcode" => array("type" => "text""label" => "Account No.""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"payease_bank_address"            => array("type" => "text""label" => "Bank Address""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"address_of_payee"                 => array("type" => "text""label" => "Address of Payee""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 2),
                    
"country_of_payee"                => array("type" => "select""label" => "Country of Payee""required" => """disabled" => """class" => "select2""value" => """enable_value" => $country_enable_value"step" => 2),
                    
"payment_transaction_code"        => array("type" => "text""label" => "Payment Transaction Code""required" => """disabled" => "disabled""class" => """value" => "121030""enable_value" => array(), "step" => 2),
                    
"payment_purposes"                => array("type" => "text""label" => "Payment Purposes""required" => """disabled" => "disabled""class" => """value" => "Cross-border FX Payment""enable_value" => array(), "step" => 2),
                    
"country_of_bank"                 => array("type" => "select""label" => "Country of Bank""required" => """disabled" => """class" => "select2""value" => """enable_value" => $country_enable_value"step" => 2),

                );
            } else if (
$type == "WEBADMIN") {
                
$form_list = array(
                    
//separate
                    
"webadmin_info"               => array("type" => "legend""label" => "Extra Information for Admin Input""step" => 1),
                    
"application_status"          => array("type" => "select""label" => "Application Status""required" => """disabled" => """class" => "select2""value" => """enable_value" => $application_status_enable_value"step" => 1),
                    
"contract_no"                 => array("type" => "text""label" => "Contract No.""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 1),
                    
"payease_sub_merchant_number" => array("type" => "text""label" => "Payease Sub-Merchant Number""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 1),
                    
"settlement_type"             => array("type" => "radio""label" => "Partner / Agent""required" => """disabled" => """class" => """value" => """enable_value" => array("supplier" => "Partner""agent" => "Agent"), "step" => 1),
                    
"billing_method"              => array("type" => "radio""label" => "Settlement Method""required" => """disabled" => """class" => """value" => """enable_value" => array("AMOUNT" => "Total Amount""T+n" => "T+n"), "step" => 1),
                    
"billing_value"               => array("type" => "text""label" => "Settlement Value""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 1),
                    
"admin_login_name"            => array("type" => "text""label" => "Senior Administer Login Name""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 1),
                    
"admin_login_pw"              => array("type" => "text""label" => "Senior Administer Login Password""required" => """disabled" => """class" => """value" => """enable_value" => array(), "step" => 1),
                );
            }

            
$new_form_list = array();
            if (
$step == -1) {
                
$new_form_list $form_list;
            } else {
                foreach (
$form_list as $field => $row) {
                    if (
$row["step"] == $step) {
                        
$new_form_list[$field] = $row;
                    }
                }
            }

            return 
$new_form_list;
        }
    }