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