4 changed files with 984 additions and 978 deletions
@ -1,322 +1,324 @@ |
|||||
<?php |
<?php |
||||
|
|
||||
|
|
||||
require_once '../../workflow/lib/DB.php'; |
require_once '../../workflow/lib/DB.php'; |
||||
class MICalculator |
class MICalculator |
||||
{ |
{ |
||||
/** |
/** |
||||
* 計算MI |
* 計算MI |
||||
* |
* |
||||
* @param array $param |
* @param array $param |
||||
* @return void |
* @return void |
||||
*/ |
*/ |
||||
public function cal(array $param) |
public function cal(array $param) |
||||
{ |
{ |
||||
$elevator_type = $param['elevator_type']; |
$elevator_type = $param['elevator_type']; |
||||
$func = $elevator_type . "_price"; |
$func = $elevator_type . "_price"; |
||||
if (method_exists($this, $elevator_type . "_price")) { |
if (method_exists($this, $elevator_type . "_price")) { |
||||
|
|
||||
return call_user_func([$this, $func], $param); |
return call_user_func([$this, $func], $param); |
||||
} |
} |
||||
return self::error(); |
return self::error(); |
||||
} |
} |
||||
/** |
/** |
||||
* 客梯報價 maintain_kind='A' |
* 客梯報價 maintain_kind='A' |
||||
* 1.每月2次保養價格*1.25倍 |
* 1.每月2次保養價格*1.25倍 |
||||
* 2.全包價格按半包價+1500元/臺 |
* 2.全包價格按半包價+1500元/臺 |
||||
* 3.簽5年長約免費送M1係統的+2600元/臺" |
* 3.簽5年長約免費送M1係統的+2600元/臺" |
||||
* @return void |
* @return void |
||||
*/ |
*/ |
||||
public function A_price(array $item) |
public function A_price(array $item) |
||||
{ |
{ |
||||
$floors = $item['floors']; |
$floors = $item['floors']; |
||||
$maintain_times = $item['maintain_times']; |
$maintain_times = $item['maintain_times']; |
||||
|
|
||||
$sql_get_price = " |
$sql_get_price = " |
||||
select |
select |
||||
elevator_type, |
elevator_type, |
||||
base_price, |
base_price, |
||||
floors_price, |
floors_price, |
||||
min_floors, |
min_floors, |
||||
min_maintain_times, |
min_maintain_times, |
||||
maintain_months, |
maintain_months, |
||||
maintain_kind, |
maintain_kind, |
||||
maintain_period, |
maintain_period, |
||||
is_m1_bundle, |
is_m1_bundle, |
||||
all_inclusive_fee, |
all_inclusive_fee, |
||||
maintenance_fee_coefficient, |
maintenance_fee_coefficient, |
||||
m1_bundle_fee |
m1_bundle_fee |
||||
from maintain_mi_option where |
from maintain_mi_option where |
||||
elevator_type='" . $item['elevator_type'] . "' |
elevator_type='" . $item['elevator_type'] . "' |
||||
and " . $item['floors'] . " between min_floors and max_floors |
and " . $item['floors'] . " between min_floors and max_floors |
||||
and " . $item['speed'] . " between min_speed and max_speed |
and " . $item['speed'] . " between min_speed and max_speed |
||||
and " . $item['persons'] . " between min_persons and max_persons |
and " . $item['persons'] . " between min_persons and max_persons |
||||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
||||
and maintain_months= " . $item['maintain_months'] . " |
and maintain_months= " . $item['maintain_months'] . " |
||||
and maintain_kind='" . $item['maintain_kind'] . "' |
and maintain_kind='" . $item['maintain_kind'] . "' |
||||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
||||
"; |
"; |
||||
|
|
||||
list($row) = DB::result($sql_get_price); |
list($row) = DB::result($sql_get_price); |
||||
if (empty($row)) return self::error(); |
if (empty($row)) return self::error(); |
||||
#1基礎價格 |
#1基礎價格 |
||||
$floors = $item['floors'] - $row['min_floors']; |
$floors = $item['floors'] - $row['min_floors']; |
||||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
||||
// echo $price1; |
// echo $price1; |
||||
#判斷是否全包 |
#判斷是否全包 |
||||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
||||
// echo $price2; |
// echo $price2; |
||||
#判斷是否五年M1套餐 |
#判斷是否五年M1套餐 |
||||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
||||
// echo $price3; |
// echo $price3; |
||||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
||||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
||||
$price4 = $price3; |
$price4 = $price3; |
||||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
||||
|
|
||||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
||||
} |
} |
||||
return self::success($price4); |
return self::success($price4); |
||||
} |
} |
||||
|
|
||||
/** |
/** |
||||
* 貨梯報價 |
* 貨梯報價 |
||||
* |
* |
||||
* @return void |
* @return void |
||||
*/ |
*/ |
||||
|
|
||||
public function B_price($item) |
public function B_price($item) |
||||
{ |
{ |
||||
|
|
||||
$floors = $item['floors']; |
$floors = $item['floors']; |
||||
$maintain_times = $item['maintain_times']; |
$maintain_times = $item['maintain_times']; |
||||
|
|
||||
$sql_get_price = " |
$sql_get_price = " |
||||
select |
select |
||||
elevator_type, |
elevator_type, |
||||
base_price, |
base_price, |
||||
floors_price, |
floors_price, |
||||
min_floors, |
min_floors, |
||||
min_maintain_times, |
min_maintain_times, |
||||
maintain_months, |
maintain_months, |
||||
maintain_kind, |
maintain_kind, |
||||
maintain_period, |
maintain_period, |
||||
is_m1_bundle, |
is_m1_bundle, |
||||
all_inclusive_fee, |
all_inclusive_fee, |
||||
maintenance_fee_coefficient, |
maintenance_fee_coefficient, |
||||
m1_bundle_fee |
m1_bundle_fee |
||||
from maintain_mi_option where |
from maintain_mi_option where |
||||
elevator_type='" . $item['elevator_type'] . "' |
elevator_type='" . $item['elevator_type'] . "' |
||||
and " . $item['floors'] . " between min_floors and max_floors |
and " . $item['floors'] . " between min_floors and max_floors |
||||
and " . $item['weight'] . " between min_weight and max_weight |
and " . $item['weight'] . " between min_weight and max_weight |
||||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
||||
and maintain_months= " . $item['maintain_months'] . " |
and maintain_months= " . $item['maintain_months'] . " |
||||
and maintain_kind='" . $item['maintain_kind'] . "' |
and maintain_kind='" . $item['maintain_kind'] . "' |
||||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
||||
"; |
"; |
||||
list($row) = DB::result($sql_get_price); |
list($row) = DB::result($sql_get_price); |
||||
if (empty($row)) return self::error(); |
if (empty($row)) return self::error(); |
||||
#1基礎價格 |
#1基礎價格 |
||||
$floors = $item['floors'] - $row['min_floors']; |
$floors = $item['floors'] - $row['min_floors']; |
||||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
||||
// echo $price1; |
// echo $price1; |
||||
#判斷是否全包 |
#判斷是否全包 |
||||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
||||
// echo $price2; |
// echo $price2; |
||||
#判斷是否五年M1套餐 |
#判斷是否五年M1套餐 |
||||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
||||
// echo $price3; |
// echo $price3; |
||||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
||||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
||||
$price4 = $price3; |
$price4 = $price3; |
||||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
||||
|
|
||||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
||||
} |
} |
||||
return self::success($price4); |
return self::success($price4); |
||||
} |
} |
||||
/** |
/** |
||||
* 病床梯報價 |
* 病床梯報價 |
||||
* |
* |
||||
* @return void |
* @return void |
||||
*/ |
*/ |
||||
|
|
||||
public function C_price($item) |
public function C_price($item) |
||||
{ |
{ |
||||
|
|
||||
$floors = $item['floors']; |
$floors = $item['floors']; |
||||
$maintain_times = $item['maintain_times']; |
$maintain_times = $item['maintain_times']; |
||||
|
|
||||
$sql_get_price = " |
$sql_get_price = " |
||||
select |
select |
||||
elevator_type, |
elevator_type, |
||||
base_price, |
base_price, |
||||
floors_price, |
floors_price, |
||||
min_floors, |
min_floors, |
||||
min_maintain_times, |
min_maintain_times, |
||||
maintain_months, |
maintain_months, |
||||
maintain_kind, |
maintain_kind, |
||||
maintain_period, |
maintain_period, |
||||
is_m1_bundle, |
is_m1_bundle, |
||||
all_inclusive_fee, |
all_inclusive_fee, |
||||
maintenance_fee_coefficient, |
maintenance_fee_coefficient, |
||||
m1_bundle_fee |
m1_bundle_fee |
||||
from maintain_mi_option where |
from maintain_mi_option where |
||||
elevator_type='" . $item['elevator_type'] . "' |
elevator_type='" . $item['elevator_type'] . "' |
||||
and " . $item['floors'] . " between min_floors and max_floors |
and " . $item['floors'] . " between min_floors and max_floors |
||||
and " . $item['weight'] . " between min_weight and max_weight |
and " . $item['weight'] . " between min_weight and max_weight |
||||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
||||
and maintain_months= " . $item['maintain_months'] . " |
and maintain_months= " . $item['maintain_months'] . " |
||||
and maintain_kind='" . $item['maintain_kind'] . "' |
and maintain_kind='" . $item['maintain_kind'] . "' |
||||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
||||
"; |
"; |
||||
list($row) = DB::result($sql_get_price); |
list($row) = DB::result($sql_get_price); |
||||
if (empty($row)) return self::error(); |
if (empty($row)) return self::error(); |
||||
#1基礎價格 |
#1基礎價格 |
||||
$floors = $item['floors'] - $row['min_floors']; |
$floors = $item['floors'] - $row['min_floors']; |
||||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
||||
// echo $price1; |
// echo $price1; |
||||
#判斷是否全包 |
#判斷是否全包 |
||||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
||||
// echo $price2; |
// echo $price2; |
||||
#判斷是否五年M1套餐 |
#判斷是否五年M1套餐 |
||||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
||||
// echo $price3; |
// echo $price3; |
||||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
||||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
||||
$price4 = $price3; |
$price4 = $price3; |
||||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
||||
|
|
||||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
||||
} |
} |
||||
return self::success($price4); |
return self::success($price4); |
||||
} |
} |
||||
|
|
||||
/** |
/** |
||||
* 無機房報價 |
* 無機房報價 |
||||
* |
* |
||||
* @return void |
* @return void |
||||
*/ |
*/ |
||||
|
|
||||
public function D_price($item) |
public function D_price($item) |
||||
{ |
{ |
||||
|
|
||||
|
|
||||
$floors = $item['floors']; |
$floors = $item['floors']; |
||||
$maintain_times = $item['maintain_times']; |
$maintain_times = $item['maintain_times']; |
||||
|
|
||||
$sql_get_price = " |
$sql_get_price = " |
||||
select |
select |
||||
elevator_type, |
elevator_type, |
||||
base_price, |
base_price, |
||||
floors_price, |
floors_price, |
||||
min_floors, |
min_floors, |
||||
min_maintain_times, |
min_maintain_times, |
||||
maintain_months, |
maintain_months, |
||||
maintain_kind, |
maintain_kind, |
||||
maintain_period, |
maintain_period, |
||||
is_m1_bundle, |
is_m1_bundle, |
||||
all_inclusive_fee, |
all_inclusive_fee, |
||||
maintenance_fee_coefficient, |
maintenance_fee_coefficient, |
||||
m1_bundle_fee |
m1_bundle_fee |
||||
from maintain_mi_option where |
from maintain_mi_option where |
||||
elevator_type='" . $item['elevator_type'] . "' |
elevator_type='" . $item['elevator_type'] . "' |
||||
and " . $item['floors'] . " between min_floors and max_floors |
and " . $item['floors'] . " between min_floors and max_floors |
||||
and " . $item['persons'] . " between min_persons and max_persons |
and " . $item['persons'] . " between min_persons and max_persons |
||||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
||||
and maintain_months= " . $item['maintain_months'] . " |
and maintain_months= " . $item['maintain_months'] . " |
||||
and maintain_kind='" . $item['maintain_kind'] . "' |
and maintain_kind='" . $item['maintain_kind'] . "' |
||||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
||||
"; |
"; |
||||
list($row) = DB::result($sql_get_price); |
list($row) = DB::result($sql_get_price); |
||||
if (empty($row)) return self::error(); |
if (empty($row)) return self::error(); |
||||
#1基礎價格 |
#1基礎價格 |
||||
$floors = $item['floors'] - $row['min_floors']; |
$floors = $item['floors'] - $row['min_floors']; |
||||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
||||
// echo $price1; |
// echo $price1; |
||||
#判斷是否全包 |
#判斷是否全包 |
||||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
||||
// echo $price2; |
// echo $price2; |
||||
#判斷是否五年M1套餐 |
#判斷是否五年M1套餐 |
||||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
||||
// echo $price3; |
// echo $price3; |
||||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
||||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
||||
$price4 = $price3; |
$price4 = $price3; |
||||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
||||
|
|
||||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
||||
} |
} |
||||
return self::success($price4); |
return self::success($price4); |
||||
} |
} |
||||
/** |
/** |
||||
*家用梯報價 |
*家用梯報價 |
||||
* |
* |
||||
* @return void |
* @return void |
||||
*/ |
*/ |
||||
|
|
||||
public function E_price(array $item) |
public function E_price(array $item) |
||||
{ |
{ |
||||
|
|
||||
$floors = $item['floors']; |
$floors = $item['floors']; |
||||
$maintain_times = $item['maintain_times']; |
$maintain_times = $item['maintain_times']; |
||||
|
|
||||
$sql_get_price = " |
$sql_get_price = " |
||||
select |
select |
||||
elevator_type, |
elevator_type, |
||||
base_price, |
base_price, |
||||
floors_price, |
floors_price, |
||||
min_floors, |
min_floors, |
||||
min_maintain_times, |
min_maintain_times, |
||||
maintain_months, |
maintain_months, |
||||
maintain_kind, |
maintain_kind, |
||||
maintain_period, |
maintain_period, |
||||
is_m1_bundle, |
is_m1_bundle, |
||||
all_inclusive_fee, |
all_inclusive_fee, |
||||
maintenance_fee_coefficient, |
maintenance_fee_coefficient, |
||||
m1_bundle_fee |
m1_bundle_fee |
||||
from maintain_mi_option where |
from maintain_mi_option where |
||||
elevator_type='" . $item['elevator_type'] . "' |
elevator_type='" . $item['elevator_type'] . "' |
||||
and " . $item['floors'] . " between min_floors and max_floors |
and " . $item['floors'] . " between min_floors and max_floors |
||||
and " . $item['persons'] . " between min_persons and max_persons |
and " . $item['persons'] . " between min_persons and max_persons |
||||
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times |
||||
and maintain_period= " . $item['maintain_period'] . " |
and maintain_period= " . $item['maintain_period'] . " |
||||
and maintain_kind='" . $item['maintain_kind'] . "' |
and maintain_kind='" . $item['maintain_kind'] . "' |
||||
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
and is_m1_bundle='" . $item['is_m1_bundle'] . "' |
||||
"; |
"; |
||||
list($row) = DB::result($sql_get_price); |
echo $sql_get_price; |
||||
if (empty($row)) return self::error(); |
|
||||
#1基礎價格 |
list($row) = DB::result($sql_get_price); |
||||
$floors = $item['floors'] - $row['min_floors']; |
if (empty($row)) return self::error(); |
||||
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
#1基礎價格 |
||||
// echo $price1; |
$floors = $item['floors'] - $row['min_floors']; |
||||
#判斷是否全包 |
$price1 = $row['base_price'] + ($floors) * $row['floors_price']; |
||||
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
// echo $price1; |
||||
// echo $price2; |
#判斷是否全包 |
||||
#判斷是否五年M1套餐 |
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1; |
||||
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
// echo $price2; |
||||
// echo $price3; |
#判斷是否五年M1套餐 |
||||
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2; |
||||
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
// echo $price3; |
||||
$price4 = $price3; |
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3); |
||||
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times |
||||
|
$price4 = $price3; |
||||
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) { |
||||
} |
|
||||
return self::success($price4); |
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient']; |
||||
} |
} |
||||
public function error() |
return self::success($price4); |
||||
{ |
} |
||||
return [ |
public function error() |
||||
'status' => 'fail', |
{ |
||||
'message' => '無此項目,請聯係業務部創建MI' |
return [ |
||||
]; |
'status' => 'fail', |
||||
} |
'message' => '無此項目,請聯係業務部創建MI' |
||||
public function success($price) |
]; |
||||
{ |
} |
||||
return [ |
public function success($price) |
||||
'status' => 'ok', |
{ |
||||
'price' => $price |
return [ |
||||
]; |
'status' => 'ok', |
||||
} |
'price' => $price |
||||
} |
]; |
||||
|
} |
||||
|
} |
||||
|
File diff suppressed because it is too large
Loading…
Reference in new issue