Browse Source

保養簽回修正

main
Cheng 1 year ago
parent
commit
562ab209d2
  1. 13
      wms/T8_Authorization_from_bpm.php
  2. 2
      wms/bonus/maintainance_bonus.php
  3. 748
      wms/bonus/maintance/maintaenance_contract_bonus.php
  4. 96
      wms/bonus/maintance/maintenance_contract_bonus_v2_0.php
  5. 171
      wms/bonus/maintance/maintenance_contract_bonus_v2_0_examination.php
  6. 4
      wms/bonus/other/maintenance_contract_bonus_v2_1.php
  7. 2
      wms/contract/api/T8api.php
  8. 22
      wms/contract/api/getContractData.php
  9. 82
      wms/contract/api/getT8NewContractData.php
  10. 898
      wms/contract/api/postContractData.php
  11. 175
      wms/contract/api/test copy.json
  12. 4
      wms/contract/conn.php
  13. 155
      wms/contract/contract-input.php
  14. 23
      wms/contract/js/alpine.js

13
wms/T8_Authorization_from_bpm.php

@ -11,15 +11,15 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119")
// $now = gmdate("YmdHis"); // $now = gmdate("YmdHis");
$now = gmdate("YmdHis", strtotime("-2 minutes")); $now = gmdate("YmdHis", strtotime("-2 minutes"));
$data = "$user_id." . $now; $data = "$user_id." . $now;
// $sign = hash_hmac('SHA256', $data, 'A21181F1EE4966D3', false); $sign = hash_hmac('SHA256', $data, 'A21181F1EE4966D3', false); ///測試區
$sign = hash_hmac('SHA256', $data, '91EB2CB12C3F8211', false); // $sign = hash_hmac('SHA256', $data, '91EB2CB12C3F8211', false);
// echo $sign; // echo $sign;
$apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'; // $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
// $apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; $apiurl = 'http://60.244.87.101:880//twWebAPI/GetAuth'; /// 測試區
// $apiurl = 'http://101.132.66.206:880/twWebAPI/GetAuth'; // $apiurl = 'http://101.132.66.206:880/twWebAPI/GetAuth';
// $apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth'; // $apiurl = 'http://10.10.145.2:880//twWebAPI/GetAuth'; /// 正式區
// $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth'; // $apiurl = 'https://erp.masada.com.tw:780/twWebAPI/GetAuth';
//GroupId : TEST測試區 ; MASADA正式區 //GroupId : TEST測試區 ; MASADA正式區
@ -28,7 +28,8 @@ function get_Auth($user_id = "M0000", $user_password = "M012290493119")
"Pwd: $user_password", "Pwd: $user_password",
"TimestampUTC: $now", "TimestampUTC: $now",
"Sign: $sign", "Sign: $sign",
"GroupId:MASADA" "GroupId:TEST"
// "GroupId:MASADA"
]; ];
$ch = curl_init(); $ch = curl_init();

2
wms/bonus/maintainance_bonus.php

@ -24,7 +24,7 @@ $bonus_status = [
'5' => '人事審核確認' '5' => '人事審核確認'
]; ];
$clause = ''; $clause = '';
if ($user_id != 'M0225') { if ($user_id != 'M0225' || $user_id != 'M0012' || $user_id != 'M0029') {
$clause .= "AND receiver == '$user_id'"; $clause .= "AND receiver == '$user_id'";
} }
if (!empty($_GET['check'])) { if (!empty($_GET['check'])) {

748
wms/bonus/maintance/maintaenance_contract_bonus.php

@ -0,0 +1,748 @@
<?php
## 3/31 前套用 2.0 版本
function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years, $discount, $fee_per_st, $receivable_date_due, $sales_id, $region_manger_id, $regular_contract_manger_id = '')
{
$bonus_array = [];
if ($ver == "2.0") {
#契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
switch ($contract_type) {
case "new":
#契約員獎金($sales_bonus)
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st) * 0.6;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.7;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.8;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.9;
break;
};
#地區經理經理獎金($region_manager_bonus)
$region_manager_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
if (($regular_contract_manger_id) != '') {
$regular_contract_manger_bonus = 100;
}
break;
case "free_to_charge":
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st) * 0.3;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.35;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.4;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.5;
break;
};
#地區經理經理獎金($region_manager_bonus)
$region_manager_bonus = 100;
#專任契約經理獎金($regular_contract_manger_bonus)
if (($regular_contract_manger_id) != '') {
$regular_contract_manger_bonus = 100;
}
break;
case "renew_priceissue":
switch ($fee_per_st) {
case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st) * 0.25;
break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.3;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.35;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.4;
break;
};
#地區經理經理獎金($region_manager_bonus)
$region_manager_bonus = 100;
#專任契約經理獎金($regular_contract_manger_bonus)
if (($regular_contract_manger_id) != '') {
$regular_contract_manger_bonus = 100;
}
break;
};
#合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59)
switch ($discount) {
case ($discount < 0.6):
$sales_bonus = $sales_bonus * 0.7;
break;
case ($discount >= 0.6 and $discount < 0.8):
$sales_bonus = $sales_bonus * 0.8;
break;
case ($discount >= 0.8):
$sales_bonus = $sales_bonus * 1.0;
break;
};
#簽約年數($contract_years):1年(1),超過1年(above)
switch ($contract_years) {
case $contract_years == "one":
#契約員獎金
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#地區經理經理獎金
array_push($bonus_array, [
"bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#專任契約經理獎金
if (($regular_contract_manger_id) != '') {
array_push($bonus_array, [
"bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
}
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
break;
case $contract_years == "above_two":
/*** 以下第1年獎金 ***/
#契約員獎金
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#地區經理經理獎金
array_push($bonus_array, [
"bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#專任契約經理獎金
if (($regular_contract_manger_id) != '') {
array_push($bonus_array, [
"bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
}
/*** 以上第1年獎金 ***/
/*** 以下第2年獎金 ***/
#第2年契約員獎金
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#第2年地區經理經理獎金
array_push($bonus_array, [
"bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
#第2年專任契約經理獎金
if (($regular_contract_manger_id) != '') {
array_push($bonus_array, [
"bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]);
}
/*** 以上第2年獎金 ***/
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
break;
}
} else {
array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額
"pay_day_due" => "9999-1-1", #預計發放時間
"bonus_regulation" => "error" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
}
return $result_array;
};
## 4/1 後套用 2.1 版本
function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id = '')
{
// $fee_per_st = round($fee_per_st);
$bonus_array = [];
if ($ver == "2.1") {
$discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2);
// $discount = ($fee_per_st - $commission_fee) / $elevator_list_price;
#契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
switch ($contract_type) {
case "new":
#契約員獎金($sales_bonus)
#合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59)
switch ($discount) {
case ($discount >= 0.8):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.6;
break;
case ($fee_per_st >= 3000 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.7;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.8;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.9;
break;
};
break;
case ($discount >= 0.6 and $discount < 0.8):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.48;
break;
case ($fee_per_st >= 3000 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.56;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.64;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.72;
break;
};
break;
case ($discount < 0.6):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.42;
break;
case ($fee_per_st >= 3000 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.49;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.56;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.63;
break;
};
break;
};
#地區處長獎金($region_director_bonus)
$region_director_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 300;
break;
case "free_to_charge":
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.3;
break;
case ($fee_per_st >= 3000 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.35;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.4;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.45;
break;
};
#地區處長獎金($region_director_bonus)
$region_director_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 300;
break;
case "renew_priceissue":
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.25;
break;
case ($fee_per_st >= 3000 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st) * 0.3;
break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st) * 0.35;
break;
case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st) * 0.4;
break;
};
#地區處長獎金($region_director_bonus)
$region_director_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 300;
break;
};
#地區處長獎金
array_push($bonus_array, [
"bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_director_id, #發放人員
"bonus_amount" => round($region_director_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "第1次款項收回後,次月發放" #發放規定
]);
#專任契約經理獎金
if ($regular_contract_manger_id != '') {
array_push($bonus_array, [
"bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "第1次款項收回後,次月發放" #發放規定
]);
}
#契約員獎金
switch ($payment_period) {
#年付
case "annually":
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
break;
#半年付
case "semiannually":
$payment_ratio_due_array = array(0.5, 0.5);
$payday_due_array = array(1, 7);
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
#季付
case "quarterly":
$payment_ratio_due_array = array(0.25, 0.25, 0.25, 0.25);
$payday_due_array = array(1, 4, 7, 10);
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
#2月1次
case "bimonthly":
$payment_ratio_due_array = array();
for ($i = 0; $i < 6; $i++) {
array_push($payment_ratio_due_array, 1 / 6);
}
$payday_due_array = array(1, 3, 5, 7, 9, 11);
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
#月付
case "monthly":
$payment_ratio_due_array = array();
// $payment_ratio_due_array = array();
for ($i = 0; $i < 12; $i++) {
array_push($payment_ratio_due_array, 1 / 12);
}
$payday_due_array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
}
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
} else {
array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額
"pay_day_due" => "9999-1-1", #預計發放時間
"bonus_regulation" => "error" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
}
return $result_array;
};
## 五年以上長約
function maintenance_longterm_contract_m1_free_charge_bonus_v2_1($ver, $contract_type, $payment_period, $payment_period_amount, $elevator_list_price, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id = '')
{
$bonus_array = [];
if ($ver == "2.1") {
$discount = ($fee_per_st - $commission_fee) / $elevator_list_price;
#契約總類($contract_type):簽長約並免費送M1 (longcontract_m1_free_charge)
switch ($contract_type) {
case "longcontract_m1_free_charge":
#契約員獎金($sales_bonus)
#合約折扣率($discount):大於80%以上(含)(above_80)、60-79%(含)以上(60_to_79)、折扣率59% (含)以下(below_59)
switch ($discount) {
case ($discount >= 0.8):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.6;
break;
case ($fee_per_st >= 3000 and $fee_per_st < 4000):
$sales_bonus = ($fee_per_st) * 0.7;
break;
case ($fee_per_st >= 4000 and $fee_per_st < 5000):
$sales_bonus = ($fee_per_st) * 0.8;
break;
case ($fee_per_st >= 5000 and $fee_per_st < 6000):
$sales_bonus = ($fee_per_st) * 0.9;
break;
case ($fee_per_st >= 6000):
$sales_bonus = ($fee_per_st) * 1.0;
break;
};
break;
case ($discount >= 0.6 and $discount < 0.8):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.42;
break;
case ($fee_per_st >= 3000 and $fee_per_st <= 4000):
$sales_bonus = ($fee_per_st) * 0.49;
break;
case ($fee_per_st >= 4000 and $fee_per_st < 5000):
$sales_bonus = ($fee_per_st) * 0.56;
break;
case ($fee_per_st >= 5000 and $fee_per_st < 6000):
$sales_bonus = ($fee_per_st) * 0.63;
break;
case ($fee_per_st >= 6000):
$sales_bonus = ($fee_per_st) * 0.7;
break;
};
break;
case ($discount < 0.6):
switch ($fee_per_st) {
case ($fee_per_st < 3000):
$sales_bonus = ($fee_per_st) * 0.3;
break;
case ($fee_per_st >= 3000 and $fee_per_st < 4000):
$sales_bonus = ($fee_per_st) * 0.35;
break;
case ($fee_per_st >= 4000 and $fee_per_st < 5000):
$sales_bonus = ($fee_per_st) * 0.4;
break;
case ($fee_per_st >= 5000 and $fee_per_st < 6000):
$sales_bonus = ($fee_per_st) * 0.45;
break;
case ($fee_per_st >= 6000):
$sales_bonus = ($fee_per_st) * 0.5;
break;
};
break;
};
#地區處長獎金($region_director_bonus)
$region_director_bonus = 170;
#專任契約經理獎金($regular_contract_manger_bonus)
$regular_contract_manger_bonus = 300;
break;
};
#付款方式$payment_period: 每月支付(monthly), 2月1次(bimonthly), 季付(quarterly), 半年付(semiannually), 年付(annually)
array_push($bonus_array, [
"bonus_type" => "2", #獎金名稱
"bonus_receiver" => $region_director_id, #發放人員
"bonus_amount" => round($region_director_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +12 months")), #預計發放時間
"bonus_regulation" => "訂金收回後次月發放" #發放規定
]);
#專任契約經理獎金
if ($regular_contract_manger_id != '') {
array_push($bonus_array, [
"bonus_type" => "3", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +12 months")), #預計發放時間
"bonus_regulation" => "訂金收回後次月發放" #發放規定
]);
}
#地區處長獎金、專任契約經理、契約員獎金
switch ($payment_period) {
#簽長約免費贈送控制系統,因屬於公司特殊政策,所以無汰改獎金,合約期內每月領取契約獎金
#總支付期數$payment_period_amount: 總支付期數,依規定5年約至少60期,
#年繳
case 'annually':
$payment_ratio_due_array = array();
$a = $payment_period_amount / 12;
for ($i = 0; $i < $a; $i++) {
array_push($payment_ratio_due_array, 1 / $a);
}
$payday_due_array = array();
for ($i = 0; $i < $a; $i++) {
array_push($payday_due_array, $i + 1);
}
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] year")), #預計發放時間
"bonus_regulation" => "每次收款後,按收款比率次月發放" #發放規定
]);
}
break;
#半年繳
case 'semiannually':
$payment_ratio_due_array = array();
$a = $payment_period_amount / 6;
for ($i = 0; $i < $a; $i++) {
array_push($payment_ratio_due_array, 1 / $a);
}
$payday_due_array = array();
for ($i = 0; $i < $a; $i++) {
array_push($payday_due_array, ($i + 1) * 6);
}
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每次收款後,按收款比率次月發放" #發放規定
]);
}
break;
#季繳
case 'quarterly':
$a = $payment_period_amount / 3;
$payment_ratio_due_array = array();
for ($i = 0; $i < $a; $i++) {
array_push($payment_ratio_due_array, 1 / $a);
}
$payday_due_array = array();
for ($i = 0; $i < $a; $i++) {
array_push($payday_due_array, ($i + 1) * 4);
}
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
#雙月繳
case 'bimonthly':
$a = $payment_period_amount / 2;
$payment_ratio_due_array = array();
for ($i = 0; $i < $a; $i++) {
array_push($payment_ratio_due_array, 1 / $a);
}
$payday_due_array = array();
for ($i = 0; $i < $a; $i++) {
array_push($payday_due_array, ($i + 1) * 2);
}
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
break;
#月繳
case 'monthly':
#產生契約員每個月的獎金應發比例
$payment_ratio_due_array = array();
for ($i = 0; $i < $payment_period_amount; $i++) {
array_push($payment_ratio_due_array, 1 / $payment_period_amount);
}
$payday_due_array = array();
for ($i = 0; $i < $payment_period_amount; $i++) {
array_push($payday_due_array, $i + 1);
}
for ($i = 0; $i < count($payment_ratio_due_array); $i++) {
if ($i < count($payment_ratio_due_array) - 1) {
$current_bonus = round($sales_bonus * $payment_ratio_due_array[$i]); #金額
} else {
$current_bonus = round($sales_bonus - $i * round($sales_bonus * $payment_ratio_due_array[$i])); #最後一次金額
};
array_push($bonus_array, [
"bonus_type" => "1", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($current_bonus), #金額
"pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +$payday_due_array[$i] months")), #預計發放時間
"bonus_regulation" => "每月收款後,按收款比率次月發放" #發放規定
]);
}
break;
}
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "success", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
} else {
array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額
"pay_day_due" => "9999-1-1", #預計發放時間
"bonus_regulation" => "error" #發放規定
]);
$result_array = [
"ver" => $ver, #獎金版本
"result_status" => "error", #計算結果
"bonus_array" => $bonus_array #獎金水庫
];
}
return $result_array;
};

96
wms/bonus/maintance/maintenance_contract_bonus_v2_0.php

@ -36,28 +36,29 @@ result_array[
*/ */
## 3/31 前套用 2.0 版本
function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years, $discount, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_manger_id, $regular_contract_manger_id)
function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years, $discount, $fee_per_st, $commission_fee, $receivable_date_due, $sales_id, $region_manger_id, $regular_contract_manger_id){ {
$bonus_array = []; $bonus_array = [];
if ($ver == "2.0"){ if ($ver == "2.0") {
#契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue) #契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
switch ($contract_type){ switch ($contract_type) {
case "new": case "new":
#契約員獎金($sales_bonus) #契約員獎金($sales_bonus)
switch ($fee_per_st) { switch ($fee_per_st) {
case ($fee_per_st <= 3000): case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.6; $sales_bonus = ($fee_per_st) * 0.6;
break; break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499): case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.7; $sales_bonus = ($fee_per_st) * 0.7;
break; break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999): case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.8; $sales_bonus = ($fee_per_st) * 0.8;
break; break;
case ($fee_per_st >= 4000): case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.9; $sales_bonus = ($fee_per_st) * 0.9;
break; break;
}; };
#地區經理經理獎金($region_manager_bonus) #地區經理經理獎金($region_manager_bonus)
@ -69,16 +70,16 @@ function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years,
case "free_to_charge": case "free_to_charge":
switch ($fee_per_st) { switch ($fee_per_st) {
case ($fee_per_st <= 3000): case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.3; $sales_bonus = ($fee_per_st) * 0.3;
break; break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499): case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.35; $sales_bonus = ($fee_per_st) * 0.35;
break; break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999): case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.4; $sales_bonus = ($fee_per_st) * 0.4;
break; break;
case ($fee_per_st >= 4000): case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.5; $sales_bonus = ($fee_per_st) * 0.5;
break; break;
}; };
#地區經理經理獎金($region_manager_bonus) #地區經理經理獎金($region_manager_bonus)
@ -90,16 +91,16 @@ function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years,
case "renew_priceissue": case "renew_priceissue":
switch ($fee_per_st) { switch ($fee_per_st) {
case ($fee_per_st <= 3000): case ($fee_per_st <= 3000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.25; $sales_bonus = ($fee_per_st) * 0.25;
break; break;
case ($fee_per_st >= 3001 and $fee_per_st <= 3499): case ($fee_per_st >= 3001 and $fee_per_st <= 3499):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.3; $sales_bonus = ($fee_per_st) * 0.3;
break; break;
case ($fee_per_st >= 3500 and $fee_per_st <= 3999): case ($fee_per_st >= 3500 and $fee_per_st <= 3999):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.35; $sales_bonus = ($fee_per_st) * 0.35;
break; break;
case ($fee_per_st >= 4000): case ($fee_per_st >= 4000):
$sales_bonus = ($fee_per_st - $commission_fee) * 0.4; $sales_bonus = ($fee_per_st) * 0.4;
break; break;
}; };
#地區經理經理獎金($region_manager_bonus) #地區經理經理獎金($region_manager_bonus)
@ -124,110 +125,110 @@ function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years,
#簽約年數($contract_years):1年(1),超過1年(above) #簽約年數($contract_years):1年(1),超過1年(above)
switch ($contract_years){ switch ($contract_years) {
case $contract_years == "one": case $contract_years == "one":
#契約員獎金 #契約員獎金
array_push($bonus_array,[ array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱 "bonus_type" => "契約員獎金", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員 "bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額 "bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定 "bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]); ]);
#地區經理經理獎金 #地區經理經理獎金
array_push($bonus_array,[ array_push($bonus_array, [
"bonus_type" => "地區經理獎金", #獎金名稱 "bonus_type" => "地區經理獎金", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員 "bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額 "bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定 "bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]); ]);
#專任契約經理獎金 #專任契約經理獎金
array_push($bonus_array,[ array_push($bonus_array, [
"bonus_type" => "專任契約經理獎金", #獎金名稱 "bonus_type" => "專任契約經理獎金", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員 "bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額 "bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定 "bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]); ]);
$result_array = [ $result_array = [
"ver"=>$ver, #獎金版本 "ver" => $ver, #獎金版本
"result_status"=>"success", #計算結果 "result_status" => "success", #計算結果
"bonus_array"=>$bonus_array #獎金水庫 "bonus_array" => $bonus_array #獎金水庫
]; ];
break; break;
case $contract_years == "above_two": case $contract_years == "above_two":
/*** 以下第1年獎金 ***/ /*** 以下第1年獎金 ***/
#契約員獎金 #契約員獎金
array_push($bonus_array,[ array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱 "bonus_type" => "契約員獎金", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員 "bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額 "bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定 "bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]); ]);
#地區經理經理獎金 #地區經理經理獎金
array_push($bonus_array,[ array_push($bonus_array, [
"bonus_type" => "地區經理獎金", #獎金名稱 "bonus_type" => "地區經理獎金", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員 "bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額 "bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定 "bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]); ]);
#專任契約經理獎金 #專任契約經理獎金
array_push($bonus_array,[ array_push($bonus_array, [
"bonus_type" => "專任契約經理獎金", #獎金名稱 "bonus_type" => "專任契約經理獎金", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員 "bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額 "bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +1 months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +1 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定 "bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]); ]);
/*** 以上第1年獎金 ***/ /*** 以上第1年獎金 ***/
/*** 以下第2年獎金 ***/ /*** 以下第2年獎金 ***/
#第2年契約員獎金 #第2年契約員獎金
array_push($bonus_array,[ array_push($bonus_array, [
"bonus_type" => "契約員獎金", #獎金名稱 "bonus_type" => "契約員獎金", #獎金名稱
"bonus_receiver" => $sales_id, #發放人員 "bonus_receiver" => $sales_id, #發放人員
"bonus_amount" => round($sales_bonus), #金額 "bonus_amount" => round($sales_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +13 months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定 "bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]); ]);
#第2年地區經理經理獎金 #第2年地區經理經理獎金
array_push($bonus_array,[ array_push($bonus_array, [
"bonus_type" => "地區經理獎金", #獎金名稱 "bonus_type" => "地區經理獎金", #獎金名稱
"bonus_receiver" => $region_manger_id, #發放人員 "bonus_receiver" => $region_manger_id, #發放人員
"bonus_amount" => round($region_manager_bonus), #金額 "bonus_amount" => round($region_manager_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +13 months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定 "bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]); ]);
#第2年專任契約經理獎金 #第2年專任契約經理獎金
array_push($bonus_array,[ array_push($bonus_array, [
"bonus_type" => "專任契約經理獎金", #獎金名稱 "bonus_type" => "專任契約經理獎金", #獎金名稱
"bonus_receiver" => $regular_contract_manger_id, #發放人員 "bonus_receiver" => $regular_contract_manger_id, #發放人員
"bonus_amount" => round($regular_contract_manger_bonus), #金額 "bonus_amount" => round($regular_contract_manger_bonus), #金額
"pay_day_due" => date("Y-m-d",strtotime("$receivable_date_due +13 months")), #預計發放時間 "pay_day_due" => date("Y-m-d", strtotime("$receivable_date_due +13 months")), #預計發放時間
"bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定 "bonus_regulation" => "合約簽回及保養款項收回的次月一次性發" #發放規定
]); ]);
/*** 以上第2年獎金 ***/ /*** 以上第2年獎金 ***/
$result_array = [ $result_array = [
"ver"=>$ver, #獎金版本 "ver" => $ver, #獎金版本
"result_status"=>"success", #計算結果 "result_status" => "success", #計算結果
"bonus_array"=>$bonus_array #獎金水庫 "bonus_array" => $bonus_array #獎金水庫
]; ];
break; break;
} }
}else{ } else {
array_push($bonus_array,[ array_push($bonus_array, [
"bonus_type" => "error", #獎金名稱 "bonus_type" => "error", #獎金名稱
"bonus_receiver" => "error", #發放人員 "bonus_receiver" => "error", #發放人員
"bonus_amount" => 0, #金額 "bonus_amount" => 0, #金額
@ -235,14 +236,11 @@ function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years,
"bonus_regulation" => "error" #發放規定 "bonus_regulation" => "error" #發放規定
]); ]);
$result_array = [ $result_array = [
"ver"=>$ver, #獎金版本 "ver" => $ver, #獎金版本
"result_status"=>"error", #計算結果 "result_status" => "error", #計算結果
"bonus_array"=>$bonus_array #獎金水庫 "bonus_array" => $bonus_array #獎金水庫
]; ];
} }
return $result_array; return $result_array;
}; };
?>

171
wms/bonus/maintance/maintenance_contract_bonus_v2_0_examination.php

@ -44,89 +44,97 @@ require_once("maintenance_contract_bonus_v2_0.php");
#獎金測試 #獎金測試
$examination_array = [ $examination_array = [
#錯誤版本 #錯誤版本
["1.0","new","one",0.8,4000,333, "2014-07-01", "M0001", "M0002", "M0003"], ["1.0", "new", "one", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"],
#新簽約 #新簽約
["2.0","new","one",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元 ["2.0", "new", "one", 0.8, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元
["2.0","new","one",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元 ["2.0", "new", "one", 0.8, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元
["2.0","new","one",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元 ["2.0", "new", "one", 0.8, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元
["2.0","new","one",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元 ["2.0", "new", "one", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元
["2.0","new","one",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元 ["2.0", "new", "one", 0.7, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元
["2.0","new","one",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元 ["2.0", "new", "one", 0.7, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元
["2.0","new","one",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元 ["2.0", "new", "one", 0.7, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元
["2.0","new","one",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元 ["2.0", "new", "one", 0.7, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元
["2.0","new","one",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元 ["2.0", "new", "one", 0.6, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元
["2.0","new","one",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元 ["2.0", "new", "one", 0.6, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元
["2.0","new","one",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元 ["2.0", "new", "one", 0.6, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元
["2.0","new","one",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元 ["2.0", "new", "one", 0.6, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元
["2.0","new","above_two",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元 ["2.0", "new", "above_two", 0.8, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元
["2.0","new","above_two",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元 ["2.0", "new", "above_two", 0.8, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元
["2.0","new","above_two",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元 ["2.0", "new", "above_two", 0.8, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元
["2.0","new","above_two",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元 ["2.0", "new", "above_two", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元
["2.0","new","above_two",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元 ["2.0", "new", "above_two", 0.7, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元
["2.0","new","above_two",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元 ["2.0", "new", "above_two", 0.7, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元
["2.0","new","above_two",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元 ["2.0", "new", "above_two", 0.7, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元
["2.0","new","above_two",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元 ["2.0", "new", "above_two", 0.7, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元
["2.0","new","above_two",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元 ["2.0", "new", "above_two", 0.6, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元
["2.0","new","above_two",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元 ["2.0", "new", "above_two", 0.6, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元
["2.0","new","above_two",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元 ["2.0", "new", "above_two", 0.6, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元
["2.0","new","above_two",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、4000元 ["2.0", "new", "above_two", 0.6, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、4000元
#免保轉有費(free_to_charge) #免保轉有費(free_to_charge)
["2.0","free_to_charge","one",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元 ["2.0", "free_to_charge", "one", 0.8, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元
["2.0","free_to_charge","one",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元 ["2.0", "free_to_charge", "one", 0.8, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元
["2.0","free_to_charge","one",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元 ["2.0", "free_to_charge", "one", 0.8, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元
["2.0","free_to_charge","one",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元 ["2.0", "free_to_charge", "one", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元
["2.0","free_to_charge","one",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元 ["2.0", "free_to_charge", "one", 0.7, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元
["2.0","free_to_charge","one",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元 ["2.0", "free_to_charge", "one", 0.7, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元
["2.0","free_to_charge","one",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元 ["2.0", "free_to_charge", "one", 0.7, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元
["2.0","free_to_charge","one",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元 ["2.0", "free_to_charge", "one", 0.7, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元
["2.0","free_to_charge","one",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元 ["2.0", "free_to_charge", "one", 0.6, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元
["2.0","free_to_charge","one",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元 ["2.0", "free_to_charge", "one", 0.6, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元
["2.0","free_to_charge","one",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元 ["2.0", "free_to_charge", "one", 0.6, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元
["2.0","free_to_charge","one",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元 ["2.0", "free_to_charge", "one", 0.6, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元
["2.0","free_to_charge","above_two",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元 ["2.0", "free_to_charge", "above_two", 0.8, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元
["2.0","free_to_charge","above_two",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元 ["2.0", "free_to_charge", "above_two", 0.8, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元
["2.0","free_to_charge","above_two",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元 ["2.0", "free_to_charge", "above_two", 0.8, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元
["2.0","free_to_charge","above_two",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元 ["2.0", "free_to_charge", "above_two", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元
["2.0","free_to_charge","above_two",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元 ["2.0", "free_to_charge", "above_two", 0.7, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元
["2.0","free_to_charge","above_two",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元 ["2.0", "free_to_charge", "above_two", 0.7, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元
["2.0","free_to_charge","above_two",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元 ["2.0", "free_to_charge", "above_two", 0.7, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元
["2.0","free_to_charge","above_two",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元 ["2.0", "free_to_charge", "above_two", 0.7, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元
["2.0","free_to_charge","above_two",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元 ["2.0", "free_to_charge", "above_two", 0.6, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元
["2.0","free_to_charge","above_two",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元 ["2.0", "free_to_charge", "above_two", 0.6, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元
["2.0","free_to_charge","above_two",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元 ["2.0", "free_to_charge", "above_two", 0.6, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元
["2.0","free_to_charge","above_two",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、4000元 ["2.0", "free_to_charge", "above_two", 0.6, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、4000元
#續簽約(原價或僅契約金額異動)(renew_priceissue) #續簽約(原價或僅契約金額異動)(renew_priceissue)
["2.0","renew_priceissue","one",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元 ["2.0", "renew_priceissue", "one", 0.8, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3000元
["2.0","renew_priceissue","one",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元 ["2.0", "renew_priceissue", "one", 0.8, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3200元
["2.0","renew_priceissue","one",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元 ["2.0", "renew_priceissue", "one", 0.8, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、3500元
["2.0","renew_priceissue","one",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元 ["2.0", "renew_priceissue", "one", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.8、4000元
["2.0","renew_priceissue","one",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元 ["2.0", "renew_priceissue", "one", 0.7, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3000元
["2.0","renew_priceissue","one",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元 ["2.0", "renew_priceissue", "one", 0.7, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3200元
["2.0","renew_priceissue","one",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元 ["2.0", "renew_priceissue", "one", 0.7, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、3500元
["2.0","renew_priceissue","one",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元 ["2.0", "renew_priceissue", "one", 0.7, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.7、4000元
["2.0","renew_priceissue","one",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元 ["2.0", "renew_priceissue", "one", 0.6, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3000元
["2.0","renew_priceissue","one",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元 ["2.0", "renew_priceissue", "one", 0.6, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3200元
["2.0","renew_priceissue","one",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元 ["2.0", "renew_priceissue", "one", 0.6, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、3500元
["2.0","renew_priceissue","one",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元 ["2.0", "renew_priceissue", "one", 0.6, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、1年、折扣率0.6、4000元
["2.0","renew_priceissue","above_two",0.8,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元 ["2.0", "renew_priceissue", "above_two", 0.8, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3000元
["2.0","renew_priceissue","above_two",0.8,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元 ["2.0", "renew_priceissue", "above_two", 0.8, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3200元
["2.0","renew_priceissue","above_two",0.8,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元 ["2.0", "renew_priceissue", "above_two", 0.8, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、3500元
["2.0","renew_priceissue","above_two",0.8,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元 ["2.0", "renew_priceissue", "above_two", 0.8, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.8、4000元
["2.0","renew_priceissue","above_two",0.7,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元 ["2.0", "renew_priceissue", "above_two", 0.7, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3000元
["2.0","renew_priceissue","above_two",0.7,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元 ["2.0", "renew_priceissue", "above_two", 0.7, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3200元
["2.0","renew_priceissue","above_two",0.7,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元 ["2.0", "renew_priceissue", "above_two", 0.7, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、3500元
["2.0","renew_priceissue","above_two",0.7,4000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元 ["2.0", "renew_priceissue", "above_two", 0.7, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.7、4000元
["2.0","renew_priceissue","above_two",0.6,3000,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元 ["2.0", "renew_priceissue", "above_two", 0.6, 3000, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3000元
["2.0","renew_priceissue","above_two",0.6,3200,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元 ["2.0", "renew_priceissue", "above_two", 0.6, 3200, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3200元
["2.0","renew_priceissue","above_two",0.6,3500,333,"2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元 ["2.0", "renew_priceissue", "above_two", 0.6, 3500, 333, "2014-07-01", "M0001", "M0002", "M0003"], #新簽約、2年以上、折扣率0.6、3500元
["2.0","renew_priceissue","above_two",0.6,4000,333,"2014-07-01", "M0001", "M0002", "M0003"] #新簽約、2年以上、折扣率0.6、4000元 ["2.0", "renew_priceissue", "above_two", 0.6, 4000, 333, "2014-07-01", "M0001", "M0002", "M0003"] #新簽約、2年以上、折扣率0.6、4000元
]; ];
$a = [
'new' => '新簽約',
'free_to_charge' => '免保轉有費',
'renew_priceissue' => '續約'
];
$b = [
'one' => '一年',
'above_two' => '一年以上'
];
for ($i = 0; $i < count($examination_array); $i++) {
for($i = 0; $i<count($examination_array); $i++){
$result = maintenance_contract_bonus_v2_0( $result = maintenance_contract_bonus_v2_0(
$examination_array[$i][0], $examination_array[$i][0],
$examination_array[$i][1], $examination_array[$i][1],
@ -141,16 +149,13 @@ for($i = 0; $i<count($examination_array); $i++){
); );
echo "獎金版本:" . $result["ver"] . "<br>"; echo "獎金版本:" . $result["ver"] . "<br>";
echo "計算結果:" . $result["result_status"] . "<br>"; echo "計算結果:" . $result["result_status"] . "<br>";
echo "輸入參數說明: " . $a[$examination_array[$i][1]] . "、" . $b[$examination_array[$i][2]] . "、折扣率:" . $examination_array[$i][3] . "、合約售價:" . $examination_array[$i][4] . "、服務費:" . $examination_array[$i][5] . "、第一筆保養款項應收回日:" . $examination_array[$i][6] . "、銷售人員:" . $examination_array[$i][7] . "、地區經理獎金:" . $examination_array[$i][8] . "、專任契約經理獎金:" . $examination_array[$i][9] . "<br>";
echo "輸入參數:" . $examination_array[$i][1] . " " . $examination_array[$i][2] . " " . $examination_array[$i][3] . " " . $examination_array[$i][4] . " " echo "輸入參數:" . $examination_array[$i][1] . " " . $examination_array[$i][2] . " " . $examination_array[$i][3] . " " . $examination_array[$i][4] . " "
. $examination_array[$i][5] . " " . $examination_array[$i][6] . " " . $examination_array[$i][7]. " " . $examination_array[$i][8] . "<br>"; . $examination_array[$i][5] . " " . $examination_array[$i][6] . " " . $examination_array[$i][7] . " " . $examination_array[$i][8] . " " . $examination_array[$i][9] . "<br>";
for($j = 0; $j<count($result["bonus_array"]); $j++){ for ($j = 0; $j < count($result["bonus_array"]); $j++) {
echo "輸出結果:" . $result["bonus_array"][$j]["bonus_type"] . " " . $result["bonus_array"][$j]["bonus_receiver"] . " " echo "輸出結果:" . $result["bonus_array"][$j]["bonus_type"] . " " . $result["bonus_array"][$j]["bonus_receiver"] . " "
. $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["pay_day_due"] . " " . $result["bonus_array"][$j]["bonus_amount"] . " " . $result["bonus_array"][$j]["pay_day_due"] . " "
. $result["bonus_array"][$j]["bonus_regulation"] . "<br>"; . $result["bonus_array"][$j]["bonus_regulation"] . "<br>";
}; };
echo "-------------------------" . "<br>"; echo "-------------------------" . "<br>";
}; };
?>

4
wms/bonus/other/maintenance_contract_bonus_v2_1.php

@ -46,8 +46,8 @@ function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period,
// $fee_per_st = round($fee_per_st); // $fee_per_st = round($fee_per_st);
$bonus_array = []; $bonus_array = [];
if ($ver == "2.1") { if ($ver == "2.1") {
// $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2); $discount = round(($fee_per_st - $commission_fee) / $elevator_list_price, 2);
$discount = ($fee_per_st - $commission_fee) / $elevator_list_price; // $discount = ($fee_per_st - $commission_fee) / $elevator_list_price;
#契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue) #契約總類($contract_type):新簽約(new)、免保轉有費(free_to_charge)、續簽約(原價或僅契約金額異動)(renew_priceissue)
switch ($contract_type) { switch ($contract_type) {

2
wms/contract/api/T8api.php

@ -12,7 +12,7 @@ function T8salIncomeApply($data, $api_url)
// exit; // exit;
$header = [ $header = [
"CHI_Authorization :" . $validation, "CHI_Authorization :" . $validation,
"GroupId:MASADA" "GroupId:TEST"
]; ];
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL curl_setopt($ch, CURLOPT_URL, $api_url); // 设置请求的URL

22
wms/contract/api/getContractData.php

@ -24,10 +24,9 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont
$stmt->execute(); $stmt->execute();
$elevators = $stmt->fetchAll(PDO::FETCH_ASSOC); $elevators = $stmt->fetchAll(PDO::FETCH_ASSOC);
$count = COUNT($elevators); $count = COUNT($elevators);
// foreach ($elevators as $key => $elevator) { foreach ($elevators as $key => $elevator) {
$elevator['discount'] = round(($elevator['sold_price'] / $elevator['stand_price']), 2);
// $elevator['discount'] = ($elevator['sold_price'] / $elevator['stand_price']) * 100; }
// }
$contract['elevators'] = $elevators; $contract['elevators'] = $elevators;
$contract['num'] = $count; $contract['num'] = $count;
@ -150,28 +149,13 @@ if (isset($_GET['contractno']) && $_GET['contractno'] != '' && isset($_GET['cont
foreach ($option_results as $key => $option) { foreach ($option_results as $key => $option) {
if ($option['item_qty'] == $result['item_qty']) { if ($option['item_qty'] == $result['item_qty']) {
$result['option_price'] += intval($option['item_unit_price']); $result['option_price'] += intval($option['item_unit_price']);
// echo '1..';
// echo "<pre>";
// print_r($option['item_unit_price']);
// echo "</pre>";
} else if ($option['item_qty'] / $result['item_qty'] != 1) { } else if ($option['item_qty'] / $result['item_qty'] != 1) {
$item_qty = intval($option['item_qty']) / intval($result['item_qty']); // 總option數量 / 總電梯台數 $item_qty = intval($option['item_qty']) / intval($result['item_qty']); // 總option數量 / 總電梯台數
$result['option_price'] += intval($option['item_unit_price']) * $item_qty; $result['option_price'] += intval($option['item_unit_price']) * $item_qty;
// echo '2..';
// echo "<pre>";
// print_r(intval($option['item_unit_price']) . ' *' . $item_qty . '=' . intval($option['item_unit_price']) * $item_qty);
// echo "</pre>";
} else { } else {
$result['option_price'] += $option['item_unit_price'] * intval($option['item_qty']); $result['option_price'] += $option['item_unit_price'] * intval($option['item_qty']);
// echo '3..';
} }
// echo '<pre>';
// print_r($option['item_no'] . '--->' . $option['item_unit_price'] . '--->' . $option['item_qty']);
// echo '</pre>';
} }
// print_r($result['option_price']);
// exit();
} }
// 查詢保固延長 // 查詢保固延長
$sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='E' AND option_relate_spec = :item_no"; $sql = "SELECT * FROM pricereview_item WHERE mid =:mid AND item_group ='E' AND option_relate_spec = :item_no";

82
wms/contract/api/getT8NewContractData.php

@ -3,7 +3,8 @@ require_once('../conn.php');
$sql = "SELECT $sql = "SELECT
BillNo, -- 合約號 BillNo, -- 合約號
OAmount -- 合約未稅金額 OAmount, -- 合約未稅金額
OAmountWithTax -- 含稅金額
FROM salSalesOrder WHERE 1=1"; FROM salSalesOrder WHERE 1=1";
$stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
$stmt->execute(); $stmt->execute();
@ -19,41 +20,76 @@ foreach ($result as $key => $result) {
$no = $result['BillNo']; $no = $result['BillNo'];
$result_master['BillNo'] = $no; $result_master['BillNo'] = $no;
$firstChar = substr($no, 0, 1); $firstChar = substr($no, 0, 1);
if ($firstChar == 'M' && $key <= 100) { if ($firstChar == 'M' && $key <= 50) {
// 查詢客戶名稱 是否為戰略客戶
$sql = "SELECT BizPartnerName FROM comBusinessPartner WHERE BizPartnerId = '$no' "; $sql = "SELECT BizPartnerName FROM comBusinessPartner WHERE BizPartnerId = '$no' ";
$stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
$stmt->execute(); $stmt->execute();
$customer_name = $stmt->fetch(PDO::FETCH_ASSOC); $customer_name = $stmt->fetch(PDO::FETCH_ASSOC);
// $result_master[] = $result;
$sql = "SELECT // 查詢作番號,與每台電梯在合約的價格、站比
$sql = "SELECT * FROM salSalesOrderDetail WHERE BillNo = '$no' AND ItemType = 0";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$elevator_facilityno = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($elevator_facilityno as $elevator) {
$facilityno = $elevator['MaterialId'];
$sql = "SELECT
BillNo,
MaterialId,
OAmountWithTax, -- 含稅金額
SPrice --未稅
FROM salSalesOrderDetail WHERE BillNo = '$no' AND CU_MaterialId = '$facilityno' AND ItemType = '1' ";
$stmt = $connT8->prepare($sql);
$stmt->execute();
$elevator_amount = $stmt->fetchAll(PDO::FETCH_ASSOC);
// 單台電梯價格
$elevator_price = 0;
foreach ($elevator_amount as $amount) {
$elevator_price = $elevator_price + intval($amount['SPrice']);
}
//電梯在合約內所佔的比例
$elevator_prince_proportion = intval($result['OAmount']) / $elevator_price;
// exit;
$sql = "SELECT
BillNo, -- 合約號 BillNo, -- 合約號
PayStage, -- 收款階段 PayStage, -- 收款階段
PlanPercentage, -- 收款比例 PlanPercentage, -- 收款比例
PlanPayAmt -- 收款金額 PlanPayAmt -- 收款金額
FROM salOrderStagePay WHERE BillNo = '$no'"; FROM salOrderStagePay WHERE BillNo = '$no'";
$stmt = $connT8->prepare($sql); $stmt = $connT8->prepare($sql);
$stmt->execute(); $stmt->execute();
$Detail = $stmt->fetchAll(PDO::FETCH_ASSOC); $Detail = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (!empty($Detail)) { if (!empty($Detail)) {
foreach ($Detail as $key => $detail) { foreach ($Detail as $key => $detail) {
$detail['PlanPercentage'] = (float)$detail['PlanPercentage']; $elevator_inContract_payPrice = $elevator_prince_proportion * $detail['PlanPercentage'];
$Detail[$key]['PlanPercentage'] = $detail['PlanPercentage']; // 比例轉小數第二位 $Detail[$key]['facilityno'] = $facilityno;
$Detail[$key]['PlanPayAmt'] = intval($detail['PlanPayAmt']); // 比例金額轉整數 $detail['PlanPercentage'] = (float)$detail['PlanPercentage'];
$Detail[$key]['PlanPercentage'] = $detail['PlanPercentage']; // 比例轉小數第二位
$Detail[$key]['contract_price_total'] = intval($detail['PlanPayAmt']); // 比例金額轉整數
$Detail[$key]['elevator_inContract_payPrice'] = round($elevator_inContract_payPrice * intval($detail['PlanPayAmt']), 2);
}
} if (mb_substr($Detail[0]['PayStage'], 0, 2) == '寶佳') {
$result_master['customer_status'] = 'strategy_customer';
} else if (!empty($customer_name) && mb_substr($customer_name['BizPartnerName'], 0, 1) == '【') {
$result_master['customer_status'] = 'strategy_customer';
} else {
$result_master['customer_status'] = 'general_customer';
}
if (mb_substr($Detail[0]['PayStage'], 0, 2) == '寶佳') { $result_master['total_price'] = intval($result['OAmount']);
$result_master['customer_status'] = 'strategy_customer'; $result_master['elevotor_pay_detail'] = $Detail;
} else if (!empty($customer_name) && mb_substr($customer_name['BizPartnerName'], 0, 1) == '【') { $result_arr[] = $result_master;
$result_master['customer_status'] = 'strategy_customer'; // echo "<pre>";
} else { // print_r($result_arr);
$result_master['customer_status'] = 'general_customer'; // echo "</pre>";
} }
$result_master['total_price'] = intval($result['OAmount']);
$result_master['detail'] = $Detail;
$result_arr[] = $result_master;
} }
// exit;
// $result_master[] = $result;
} }
} }

898
wms/contract/api/postContractData.php

File diff suppressed because it is too large

175
wms/contract/api/test copy.json

@ -1,115 +1,72 @@
[ [
{ {
"name": "MainSalesOrder", "apply_key": "MB24010007",
"rows": [ "register_code": "036B017432",
{ "elevator_brand": "1",
"BillNo": "M24020076", "elevator_kind": "A",
"BillDate": 20240320, "spec": "MAE100",
"TypeId": "SO", "weight": 550,
"FOrgId": "1000", "speed": 60,
"OrgId": "1000", "stop": 12,
"ModeId": "M", "floors": 12,
"BizPartnerId": "M24020076", "persons": 8,
"CurrId": "TWD", "elevator_num": 0,
"CurrOAmount": 1, "useful_years": 83,
"CurrLAmount": 1, "last_check_date": 1121109,
"PersonId": "M0073", "speed_governors_check_expense": 0,
"DueToId": "M24020076", "maintain_times": 1,
"TradeConditionId": "", "is_m1_bundle": "N",
"TaxId": "ST005", "maintainance": "A",
"CreditorCompId": "1001", "maintain_months": "12",
"CreditorOrgId": "1000", "maintain_period": 1,
"CreatorId": "M0225" "stand_price": 3140,
} "contract_price": 1666.67,
] "sold_price": 1667,
"commission_expense": null,
"management_expense": null,
"annual_survey_expense": 0,
"service_expense": 2,
"cmstatus": "Y",
"updated_at": null,
"creater": null,
"created_at": "2024-01-10 11:16:26",
"discount": 0.5301496815286625,
"bonus_verson": "2.0",
"manager": "M0137"
}, },
{ {
"name": "SubOrder", "apply_key": "MB24010007",
"rows": [ "register_code": "036B032903",
{ "elevator_brand": "1",
"TaxId": "ST005", "elevator_kind": "A",
"RequirementDate": 20240320, "spec": "MAE100",
"ConsignmentDate": 20240320, "weight": 450,
"BillNo": "M24020076", "speed": 60,
"RowCode": 1, "stop": 7,
"ItemType": 1, "floors": 7,
"MaterialId": "A40001", "persons": 6,
"SUnitId": "SET", "elevator_num": 0,
"SQuantity": 1, "useful_years": 83,
"SPrice": 910000, "last_check_date": 1121109,
"CU_MaterialId": "4MW00001" "speed_governors_check_expense": 0,
}, "maintain_times": 1,
{ "is_m1_bundle": "N",
"TaxId": "ST005", "maintainance": "A",
"RequirementDate": 20240320, "maintain_months": "12",
"ConsignmentDate": 20240320, "maintain_period": 1,
"BillNo": "M24020076", "stand_price": 2540,
"RowCode": 2, "contract_price": 1666.67,
"ItemType": 1, "sold_price": 1667,
"MaterialId": "A40008", "commission_expense": null,
"SUnitId": "SET", "management_expense": null,
"SQuantity": 1, "annual_survey_expense": 0,
"SPrice": 390000, "service_expense": 2,
"CU_MaterialId": "4MW00001" "cmstatus": "Y",
}, "updated_at": null,
{ "creater": null,
"TaxId": "ST005", "created_at": "2024-01-10 11:16:26",
"RequirementDate": 20240320, "discount": 0.6553818897637795,
"ConsignmentDate": 20240320, "bonus_verson": "2.0",
"BillNo": "M24020076", "manager": "M0137"
"RowCode": 3,
"ItemType": 0,
"MaterialId": "4MW00001",
"SUnitId": "SET",
"SQuantity": 1,
"SPrice": 0,
"CU_MaterialId": "4MW00001"
}
]
},
{
"name": "salOrderStagePay",
"rows": [
{
"PayStage": "簽約",
"PlanPercentage": 0.2,
"PlanPayAmt": 260000,
"PlanPayDate": 20240420,
"BillNo": "M24020076",
"RowCode": 1,
"RowNo": 1,
"UnWriteOffOAmount": 260000
},
{
"PayStage": "貨抵工地",
"PlanPercentage": 0.5,
"PlanPayAmt": 650000,
"PlanPayDate": 20241220,
"BillNo": "M24020076",
"RowCode": 2,
"RowNo": 2,
"UnWriteOffOAmount": 650000
},
{
"PayStage": "試車完工",
"PlanPercentage": 0.2,
"PlanPayAmt": 260000,
"PlanPayDate": 20250120,
"BillNo": "M24020076",
"RowCode": 3,
"RowNo": 3,
"UnWriteOffOAmount": 260000
},
{
"PayStage": "交車",
"PlanPercentage": 0.1,
"PlanPayAmt": 130000,
"PlanPayDate": 20250220,
"BillNo": "M24020076",
"RowCode": 4,
"RowNo": 4,
"UnWriteOffOAmount": 130000
}
]
} }
] ]

4
wms/contract/conn.php

@ -34,9 +34,9 @@ try {
//設定主動以警告的形式報錯 //設定主動以警告的形式報錯
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8TEST", "M0225", "IFFBU1E="); $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8TEST", "M0225", "IFFBU1E=");
// $connT8 = new PDO("sqlsrv:Server=10.10.145.2;Database=T8MASADA", "masada", "@m222222"); // $connT8 = new PDO("sqlsrv:Server=10.10.145.2;Database=T8MASADA", "masada", "@m222222");
$connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "masada", "@m222222"); // $connT8 = new PDO("sqlsrv:Server=220.130.203.251;Database=T8MASADA", "masada", "@m222222");
if ($connT8) { if ($connT8) {

155
wms/contract/contract-input.php

@ -64,7 +64,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="vertical-align: middle">立約人</td> <td style="vertical-align: middle">客戶名稱</td>
<td> <td>
<input type="text" x-model="data.customer" /> <input type="text" x-model="data.customer" />
<p class="alerttext" x-show="data.customer==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.customer==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
@ -79,7 +79,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
</select> </select>
<p class="alerttext" x-show="data.salesman==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.salesman==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align: middle">合約開始時間</td> <!-- <td style="vertical-align: middle">合約開始時間</td>
<td> <td>
<input class="form-control disabled_select" type="date" name="start_date" x-model="data.contract_begin_date"> <input class="form-control disabled_select" type="date" name="start_date" x-model="data.contract_begin_date">
<p class="alerttext" x-show="data.contract_begin_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.contract_begin_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
@ -88,29 +88,52 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<td> <td>
<input class="form-control disabled_select" type="date" name="end_date" x-model="data.contract_end_date"> <input class="form-control disabled_select" type="date" name="end_date" x-model="data.contract_end_date">
<p class="alerttext" x-show="data.contract_end_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.contract_end_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td> -->
</tr>
<tr>
<td style="vertical-align: middle">電梯台數</td> <td style="vertical-align: middle">電梯台數</td>
<td> <td>
<input class="form-control disabled_select" type="number" x-model="data.num" :disabled="data.disabled"> <input class="form-control disabled_select" type="number" x-model="data.num" :disabled="data.disabled">
<p class="alerttext" x-show="data.num==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.num==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
<p class="alerttext" x-show="data.num==0 && data.num!=''"><i class="fa-solid fa-circle-xmark"></i>電梯數量需大於0</p> <p class="alerttext" x-show="data.num==0 && data.num!=''"><i class="fa-solid fa-circle-xmark"></i>電梯數量需大於0</p>
</td> </td>
<td style="vertical-align: middle">分期方式</td>
<td style="vertical-align: middle">統一編號/身分證</td>
<td> <td>
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.vat"> <select class="ui search dropdown" x-model="data.payType">
<p class="alerttext" x-show="data.vat==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <option value="">選擇付款方式</option>
<option value="A40006">年繳</option>
<option value="A40007">季繳</option>
<option value="A40003">月繳</option>
<option value="A40004">雙月繳</option>
<option value="A40005">半年繳</option>
</select>
<p class="alerttext" x-show="data.payType==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align: middle">維修型態</td> <!-- <td style="vertical-align: middle">維修型態</td>
<td style="vertical-align: middle"> <td style="vertical-align: middle">
<select class="ui search dropdown" name="" x-model="data.mtype"> <select class="ui search dropdown" name="" x-model="data.mtype" disabled>
<option value="">選擇維修型態</option> <option value="">選擇維修型態</option>
<option value="A">定期保養</option> <option value="A">定期保養</option>
</select> </select>
<p class="alerttext" x-show="data.mtype==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.mtype==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> -->
</tr>
<tr>
<td style="vertical-align: middle">簽約日</td>
<td>
<input class="form-control disabled_select" type="date" name="end_date" x-model="data.signing_date">
<p class="alerttext" x-show="data.signing_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align: middle">合約開始時間</td>
<td>
<input class="form-control disabled_select" type="date" name="start_date" x-model="data.contract_begin_date">
<p class="alerttext" x-show="data.contract_begin_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">合約終止時間</td>
<td>
<input class="form-control disabled_select" type="date" name="end_date" x-model="data.contract_end_date">
<p class="alerttext" x-show="data.contract_end_date==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">契約成交價</td> <td style="vertical-align: middle">契約成交價</td>
<td> <td>
<input class="form-control disabled_select" type="number" name="tel" x-model="data.total_price" :disabled="data.disabled"> <input class="form-control disabled_select" type="number" name="tel" x-model="data.total_price" :disabled="data.disabled">
@ -118,26 +141,33 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="vertical-align: middle">發票抬頭</td>
<td>
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.invoice">
<!-- <p class="alerttext" x-show="data.invoice==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
<td style="vertical-align: middle">統一編號/身分證</td>
<td>
<input class="form-control disabled_select" type="text" name="uscc" x-model="data.vat">
<!-- <p class="alerttext" x-show="data.vat==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
<td style="vertical-align: middle">客戶電話</td> <td style="vertical-align: middle">客戶電話</td>
<td> <td>
<input class="form-control disabled_select" type="text" name="tel" x-model="data.phone"> <input class="form-control disabled_select" type="text" name="tel" x-model="data.phone">
<p class="alerttext" x-show="data.phone==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <!-- <p class="alerttext" x-show="data.phone==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td> </td>
<td style="vertical-align: middle">Email</td> <td style="vertical-align: middle">區域</td>
<td style="vertical-align: middle">
<input class="form-control disabled_select" type="email" name="email" x-model="data.email">
<p class="alerttext" x-show="data.email==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
<td style="vertical-align: middle">保養員</td>
<td> <td>
<select class="ui search dropdown" name="repairer_name" x-model="data.mworker"> <select class="ui search dropdown" x-model="data.area">
<option value="">選擇保養員</option> <option value="">選擇區域</option>
<?php foreach ($workers as $worker) { ?> <template x-for="city in cities" :key="city.code">
<option value="<?php echo $worker['accountid']; ?>"><?php echo $worker['name'] ?></option> <option x-bind:selected="city.name === data.area" x-text="city.name" :value="city.name"></option>
<?php } ?> </template>
</select> </select>
<p class="alerttext" x-show="data.mworker==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.area==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<!-- <td style="vertical-align: middle">保養頻率</td> <!-- <td style="vertical-align: middle">保養頻率</td>
<td> <td>
<select class="ui search dropdown" name="repairer_name" x-model="data.mcycle"> <select class="ui search dropdown" name="repairer_name" x-model="data.mcycle">
@ -147,21 +177,10 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
</select> </select>
<p class="alerttext" x-show="data.mcycle==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.mcycle==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> --> </td> -->
<td style="vertical-align: middle">分期方式</td>
<td>
<select class="ui search dropdown" x-model="data.payType">
<option value="">選擇付款方式</option>
<option value="A40006">年繳</option>
<option value="A40007">季繳</option>
<option value="A40003">月繳</option>
<option value="A40004">雙月繳</option>
<option value="A40005">半年繳</option>
</select>
<p class="alerttext" x-show="data.payType==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td>
</tr> </tr>
<tr> <!-- <tr>
<td style="vertical-align: middle">業務聯繫人</td> <td style="vertical-align: middle">合約聯繫人</td>
<td> <td>
<input type="text" x-model="data.partyA" name="partyA" /> <input type="text" x-model="data.partyA" name="partyA" />
<p class="alerttext" x-show="data.partyA==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.partyA==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
@ -181,27 +200,31 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<input class="form-control disabled_select" type="email" name="contracttel" x-model="data.partyAemail"> <input class="form-control disabled_select" type="email" name="contracttel" x-model="data.partyAemail">
<p class="alerttext" x-show="data.partyAemail==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.partyAemail==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
</tr> </tr> -->
<tr> <tr>
<td style="vertical-align: middle">區域</td>
<td>
<select class="ui search dropdown" x-model="data.area">
<option value="">選擇區域</option>
<template x-for="city in cities" :key="city.code">
<option x-bind:selected="city.name === data.area" x-text="city.name" :value="city.name"></option>
</template>
</select>
<p class="alerttext" x-show="data.area==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align: middle">詳細地址</td> <td style="vertical-align: middle">發票地址</td>
<td colspan="2">
<input type="text" x-model="data.invoice_address" />
<!-- <p class="alerttext" x-show="data.invoice_address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td>
<td style="vertical-align: middle">現場地址</td>
<td colspan="2"> <td colspan="2">
<input type="text" x-model="data.address" /> <input type="text" x-model="data.address" />
<p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> <p class="alerttext" x-show="data.address==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p>
</td> </td>
<td style="vertical-align: middle">附件</td> <td style="vertical-align: middle">保養員</td>
<td colspan="2"> <td>
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" /> <select class="ui search dropdown" name="repairer_name" x-model="data.mworker">
<option value="">選擇保養員</option>
<?php foreach ($workers as $worker) { ?>
<option value="<?php echo $worker['accountid']; ?>"><?php echo $worker['name'] ?></option>
<?php } ?>
</select>
<!-- <p class="alerttext" x-show="data.mworker==''"><i class="fa-solid fa-circle-xmark"></i>未填寫</p> -->
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="vertical-align:middle">合約類別</td> <td style="vertical-align:middle">合約類別</td>
@ -211,9 +234,21 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<option value="new">新簽約</option> <option value="new">新簽約</option>
<option value="free_to_charge">免保轉有費</option> <option value="free_to_charge">免保轉有費</option>
<option value="renew_priceissue">續簽約</option> <option value="renew_priceissue">續簽約</option>
<option value="longcontract_m1_free_charge">長約</option> <option value="longcontract_m1_free_charge">長約(保養+免費M1電控)</option>
</select> </select>
</td> </td>
<td></td>
<td></td>
<td></td>
<td style="vertical-align: middle">合約附件</td>
<td colspan="2">
<input type="file" name="file[]" multiple draggable="true" @change="uploadFiles($event)" />
</td>
</tr>
<tr>
</tr> </tr>
<!-- <tr> <!-- <tr>
<td></td> <td></td>
@ -372,7 +407,7 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<tr> <tr>
<td style="vertical-align:middle">契約人員</td> <td style="vertical-align:middle">契約人員</td>
<td><input type="text" x-model="data.salesman"></td> <td><input type="text" x-model="data.salesman"></td>
<td style="vertical-align:middle">保養月份</td> <td style="vertical-align:middle">合約總計保養月份</td>
<td> <td>
<input type="text" x-model="elevator.maintain_months"> <input type="text" x-model="elevator.maintain_months">
</td> </td>
@ -393,15 +428,9 @@ $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC);
<td><input type="text" x-model="elevator.sold_price"></td> <td><input type="text" x-model="elevator.sold_price"></td>
</tr> </tr>
<tr> <tr>
<td style="vertical-align:middle">服務費</td> <td style="vertical-align:middle">折扣率<br>(取小數點第一位)</td>
<td> <td><input type="text" x-model="elevator.discount"></td>
<input type="text" x-model="elevator.service_expense">
</td>
<td style="vertical-align:middle">牌價(標準價)</td>
<td>
<input type="text" x-model="elevator.stand_price">
<p>標準價+Option價格+與其他電梯共同分擔的費用貨價格</p>
</td>
<td style="vertical-align:middle">地區處長員工號</td> <td style="vertical-align:middle">地區處長員工號</td>
<td><input type="text" x-model="elevator.manager"></td> <td><input type="text" x-model="elevator.manager"></td>
<td style="vertical-align:middle">專任契約經理員工號</td> <td style="vertical-align:middle">專任契約經理員工號</td>

23
wms/contract/js/alpine.js

@ -1022,7 +1022,8 @@ const contractInput = () => {
disabled: false, //資料庫是否有電梯數量資料 disabled: false, //資料庫是否有電梯數量資料
elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期 elevators: [], //機種、載重、人乘、樓停、樓層、速度、緯度、經度、開門方式、保養別、廠牌、竣檢日、許可證日期
payType: '', //付款方式 payType: '', //付款方式
contract_type: 'new' contract_type: 'new',
signing_date: ''
// bonus_verson: 2.1, // bonus_verson: 2.1,
// manager: '', // manager: '',
// regular_contract_manger_id: '', // regular_contract_manger_id: '',
@ -1050,14 +1051,18 @@ const contractInput = () => {
} }
}, },
getBonusVerson(data) { getBonusVerson(data, signing_date) {
// 目前獎金版本為 2.1,若之後要依辦法建立時間來判斷在這邊修改 // 目前獎金版本為 2.1,若之後要依辦法建立時間來判斷在這邊修改
data.bonus_verson = 2.1; if (new Date(signing_date) >= new Date("2024-04-01")) {
data.bonus_verson = "2.1";
} else {
data.bonus_verson = "2.0";
}
}, },
getManager() { getManager() {
for (let i = 0; i < this.data.elevators.length; i++) { for (let i = 0; i < this.data.elevators.length; i++) {
this.getBonusVerson(this.data.elevators[i]); this.getBonusVerson(this.data.elevators[i], this.data.signing_date);
console.log(this.data.elevators[i].bonus_version);
axios.get('./api/getContractData.php?contracttype=accountManger&salesman=' + this.data.salesman).then(res => { axios.get('./api/getContractData.php?contracttype=accountManger&salesman=' + this.data.salesman).then(res => {
this.data.elevators[i].manager = res.data.manager; this.data.elevators[i].manager = res.data.manager;
console.log(this.data.elevators[i]); console.log(this.data.elevators[i]);
@ -1100,7 +1105,9 @@ const contractInput = () => {
manager: '', manager: '',
regular_contract_manger_id: '', regular_contract_manger_id: '',
bonus_verson: '', bonus_verson: '',
sold_price: '' sold_price: '',
invoice: '', //發票抬頭
invoice_address: "" //發票地址
}) })
} }
} }
@ -1122,9 +1129,10 @@ const contractInput = () => {
// 服務費 (以單筆合約記,但計算獎金須傳入單月服務費) // 服務費 (以單筆合約記,但計算獎金須傳入單月服務費)
this.data.elevators[i].service_expense = Math.round(this.data.elevators[i].service_expense / res.data.elevators[i].maintain_months); this.data.elevators[i].service_expense = Math.round(this.data.elevators[i].service_expense / res.data.elevators[i].maintain_months);
// 折扣率 // 折扣率
this.data.elevators[i].discount = ((res.data.elevators[i].sold_price - this.data.elevators[i].service_expense) / res.data.elevators[i].stand_price); this.data.elevators[i].discount = (((res.data.elevators[i].sold_price - this.data.elevators[i].service_expense) / res.data.elevators[i].stand_price).toFixed(2)) * 100;
this.data.elevators[i].sold_price = Math.round(res.data.elevators[i].sold_price); this.data.elevators[i].sold_price = Math.round(res.data.elevators[i].sold_price);
} }
console.log(this.data.elevators);
this.data.total_price = Number(res.data.elevators[0].maintain_months) * this.data.total_price; this.data.total_price = Number(res.data.elevators[0].maintain_months) * this.data.total_price;
this.data.salesman = res.data.salesman this.data.salesman = res.data.salesman
this.data.contract_begin_date = res.data.contract_begin_date this.data.contract_begin_date = res.data.contract_begin_date
@ -1220,6 +1228,7 @@ const contractInput = () => {
form.append('contracttype', 'b'); form.append('contracttype', 'b');
form.append('payType', this.data.payType); form.append('payType', this.data.payType);
form.append('contract_type', this.data.contract_type); form.append('contract_type', this.data.contract_type);
form.append('signing_date', this.data.signing_date);
// 如果有附件檔案,可以逐一加入 // 如果有附件檔案,可以逐一加入
for (var i = 0; i < this.data.files.length; i++) { for (var i = 0; i < this.data.files.length; i++) {

Loading…
Cancel
Save