6 changed files with 573 additions and 450 deletions
@ -1,322 +1,322 @@ |
|||
<?php |
|||
|
|||
|
|||
require_once '../../workflow/lib/DB.php'; |
|||
class MSCalculator |
|||
{ |
|||
/** |
|||
* 計算报价 |
|||
* |
|||
* @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_standard_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_standard_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_standard_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_standard_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_standard_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' => '無此項目,請聯係業務部創建標準成本' |
|||
]; |
|||
} |
|||
public function success($price) |
|||
{ |
|||
return [ |
|||
'status' => 'ok', |
|||
'price' => $price |
|||
]; |
|||
} |
|||
} |
|||
<?php |
|||
|
|||
|
|||
require_once '../../workflow/lib/DB.php'; |
|||
class MSCalculator |
|||
{ |
|||
/** |
|||
* 計算报价 |
|||
* |
|||
* @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_standard_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_standard_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_standard_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_standard_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_standard_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' => '無此項目,請聯係業務部創建標準成本' |
|||
]; |
|||
} |
|||
public function success($price) |
|||
{ |
|||
return [ |
|||
'status' => 'ok', |
|||
'price' => $price |
|||
]; |
|||
} |
|||
} |
|||
|
@ -1,84 +1,84 @@ |
|||
<?php |
|||
error_reporting(E_ALL); |
|||
ini_set('dispaly_errors', "On"); |
|||
require_once './MSCalculator.php'; |
|||
|
|||
|
|||
/* //客梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'A', |
|||
'floors' => 7, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
*/ |
|||
/* //货梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'B', |
|||
'floors' => 7, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
*/ |
|||
|
|||
/*//病床梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'C', |
|||
'floors' => 28, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 2, //病床梯一月2次保养 |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
];*/ |
|||
|
|||
/*//无机房 |
|||
$param = [ |
|||
'elevator_type' => 'D', |
|||
'floors' => 3, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, //病床梯一月2次保养 |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 3, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
*/ |
|||
//家用梯 |
|||
$param = [ |
|||
'elevator_type' => 'E', |
|||
'floors' => 3, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, //病床梯一月2次保养 |
|||
'maintain_months' => 60, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'Y', |
|||
]; |
|||
|
|||
$mic = new MSCalculator(); |
|||
$price = $mic->cal($_GET); |
|||
echo json_encode($price); |
|||
<?php |
|||
error_reporting(E_ALL); |
|||
ini_set('dispaly_errors', "On"); |
|||
require_once './MSCalculator.php'; |
|||
|
|||
|
|||
//客梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'A', |
|||
'floors' => 7, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
//货梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'B', |
|||
'floors' => 7, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
|
|||
//病床梯 |
|||
$param = [ |
|||
|
|||
'elevator_type' => 'C', |
|||
'floors' => 28, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 2, //病床梯一月2次保养 |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
//无机房 |
|||
$param = [ |
|||
'elevator_type' => 'D', |
|||
'floors' => 3, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, //病床梯一月2次保养 |
|||
'maintain_months' => 12, |
|||
'maintain_kind' => 3, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'N', |
|||
]; |
|||
|
|||
|
|||
//家用梯 |
|||
$param = [ |
|||
'elevator_type' => 'E', |
|||
'floors' => 3, |
|||
'speed' => 1, |
|||
'persons' => 6, |
|||
'weight' => 1000, |
|||
'maintain_times' => 1, //病床梯一月2次保养 |
|||
'maintain_months' => 60, |
|||
'maintain_kind' => 2, |
|||
'maintain_period' => 1, //默认为1月1次, 2是为2月一次 |
|||
'is_m1_bundle' => 'Y', |
|||
]; |
|||
|
|||
$mic = new MSCalculator(); |
|||
$price = $mic->cal($_GET); |
|||
echo json_encode($price); |
|||
|
Loading…
Reference in new issue