Browse Source

Merge commit '0bfea677146dfb1fb5c9226243b789e8a6ce90d1' into gary

gary
IA2301\IA_2301 1 year ago
parent
commit
0bfcbca425
  1. 17
      wms/cont/api/maintaenance_contract_bonus.php
  2. 8
      wms/cont/api/postElevatorPricereview.php
  3. 64
      wms/cont/js/pricereviewAlpine.js
  4. 19
      wms/cont/pricereviewCreate.php
  5. 0
      wms/cont/pricereviewIndex.php
  6. 3
      wms/cont/window-modal/modalElevaotr.php

17
wms/cont/api/maintaenance_contract_bonus.php

@ -5,19 +5,28 @@ $ver = isset($_GET['ver']) ? $_GET['ver'] : null;
$contract_type = isset($_GET['contract_type']) ? trim($_GET['contract_type']) : null; // 请注意删除可能的尾随空格 $contract_type = isset($_GET['contract_type']) ? trim($_GET['contract_type']) : null; // 请注意删除可能的尾随空格
$contract_years = isset($_GET['contract_years']) ? $_GET['contract_years'] : null; $contract_years = isset($_GET['contract_years']) ? $_GET['contract_years'] : null;
$discount = isset($_GET['discount']) ? $_GET['discount'] : null; $discount = isset($_GET['discount']) ? $_GET['discount'] : null;
$fee_per_st = isset($_GET['fee_per_st']) ? $_GET['fee_per_st'] : null; $fee_per_st = isset($_GET['fee_per_st']) ? (int)$_GET['fee_per_st'] : null;
$receivable_date_due = isset($_GET['receivable_date_due']) ? $_GET['receivable_date_due'] : null; $receivable_date_due = isset($_GET['receivable_date_due']) ? $_GET['receivable_date_due'] : null;
$sales_id = isset($_GET['sales_id']) ? $_GET['sales_id'] : null; $sales_id = isset($_GET['sales_id']) ? $_GET['sales_id'] : null;
$payment_period = isset($_GET['payment_period']) ? $_GET['payment_period'] : null;
$region_manager_id = isset($_GET['region_manager_id']) ? $_GET['region_manager_id'] : null; $region_manager_id = isset($_GET['region_manager_id']) ? $_GET['region_manager_id'] : null;
$regular_contract_manager_id = isset($_GET['regular_contract_manager_id']) ? $_GET['regular_contract_manager_id'] : null; $regular_contract_manager_id = isset($_GET['regular_contract_manager_id']) ? $_GET['regular_contract_manager_id'] : null;
if($ver == '2.0'){
$bonus = maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years, $discount, $fee_per_st, $receivable_date_due, $sales_id, $region_manager_id, $regular_contract_manager_id); $bonus = maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years, $discount, $fee_per_st, $receivable_date_due, $sales_id, $region_manager_id, $regular_contract_manager_id);
}
if($ver == '2.1'){
$bonus = 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 = '');
}
echo json_encode($bonus); echo json_encode($bonus);
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 = '') 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 = []; $bonus_array = [];
if ($ver == "2.0") { if ($ver == "2.0") {
$sales_bonus = 0;
$region_manager_bonus = 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":
@ -232,12 +241,12 @@ function maintenance_contract_bonus_v2_0($ver, $contract_type, $contract_years,
}; };
## 4/1 後套用 2.1 版本 ## 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 = '') function maintenance_contract_bonus_v2_1($ver, $contract_type, $payment_period, $discount, $fee_per_st, $receivable_date_due, $sales_id, $region_director_id, $regular_contract_manger_id = '')
{ {
// $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)

8
wms/cont/api/postElevatorPricereview.php

@ -12,6 +12,7 @@ $num = $_POST['num'];
$salesman = $_POST['salesman']; $salesman = $_POST['salesman'];
$contract_begin_date = $_POST['contract_begin_date']; $contract_begin_date = $_POST['contract_begin_date'];
$contract_end_date = $_POST['contract_end_date']; $contract_end_date = $_POST['contract_end_date'];
$sign_day = $_POST['signDay'];
$contract_kind = $_POST['contract_kind']; $contract_kind = $_POST['contract_kind'];
$progress_remark = $_POST['progress_status']; $progress_remark = $_POST['progress_status'];
$serviceFee = $_POST['serviceFee']; $serviceFee = $_POST['serviceFee'];
@ -129,8 +130,8 @@ if(!empty($attatch2)){
$conn->beginTransaction(); $conn->beginTransaction();
try{ try{
if(!$contract){ if(!$contract){
$sql_str = "INSERT INTO con_maintance_examine_apply (apply_key, vol_no, customer, address, case_name ,brand, num, salesman, maintain_kind, contract_begin_date, contract_end_date, contract_kind, payment_kind, progress_remark, service_fee, total_price, total_sale_price, penalty, deposit_rate, keep_rate, warranty_rate, memo, status, attatch1, attatch2, creater, create_at) $sql_str = "INSERT INTO con_maintance_examine_apply (apply_key, vol_no, customer, address, case_name ,brand, num, salesman, maintain_kind, contract_begin_date, contract_end_date, contract_kind, payment_kind, progress_remark, service_fee, total_price, total_sale_price, penalty, deposit_rate, keep_rate, warranty_rate, memo, status, attatch1, attatch2, sign_day, creater, create_at)
VALUES (:apply_key, :vol_no, :customer, :address, :case_name ,:brand, :num, :salesman, :maintain_kind, :contract_begin_date, :contract_end_date, :contract_kind, :payment_kind, :progress_remark, :service_fee, :total_price, :total_sale_price, :penalty, :deposit_rate, :keep_rate, :warranty_rate, :memo, :status, :attatch1, :attatch2, :creater, :create_at)"; VALUES (:apply_key, :vol_no, :customer, :address, :case_name ,:brand, :num, :salesman, :maintain_kind, :contract_begin_date, :contract_end_date, :contract_kind, :payment_kind, :progress_remark, :service_fee, :total_price, :total_sale_price, :penalty, :deposit_rate, :keep_rate, :warranty_rate, :memo, :status, :attatch1, :attatch2, :sign_day, :creater, :create_at)";
$stmt = $conn->prepare($sql_str); $stmt = $conn->prepare($sql_str);
$stmt->bindParam(':apply_key', $apply_key); $stmt->bindParam(':apply_key', $apply_key);
$stmt->bindParam(':vol_no', $vol_no); $stmt->bindParam(':vol_no', $vol_no);
@ -157,6 +158,7 @@ try{
$stmt->bindParam(':status', $status); $stmt->bindParam(':status', $status);
$stmt->bindParam(':attatch1', $attatch1_src); $stmt->bindParam(':attatch1', $attatch1_src);
$stmt->bindParam(':attatch2', $attatch2_src); $stmt->bindParam(':attatch2', $attatch2_src);
$stmt->bindParam(':sign_day', $sign_day);
$stmt->bindParam(':creater', $creater); $stmt->bindParam(':creater', $creater);
$stmt->bindParam(':create_at', $current_date); $stmt->bindParam(':create_at', $current_date);
$stmt->execute(); $stmt->execute();
@ -256,6 +258,7 @@ try{
status=:status, status=:status,
attatch1=:attatch1, attatch1=:attatch1,
attatch2=:attatch2, attatch2=:attatch2,
sign_day=:sign_day,
updated_at=:updated_at, updated_at=:updated_at,
progress_remark=:progress_remark progress_remark=:progress_remark
WHERE apply_key=:apply_key AND vol_no=:vol_no"; WHERE apply_key=:apply_key AND vol_no=:vol_no";
@ -282,6 +285,7 @@ try{
$stmt->bindParam(':status', $status); $stmt->bindParam(':status', $status);
$stmt->bindParam(':attatch1', $attatch1_src); $stmt->bindParam(':attatch1', $attatch1_src);
$stmt->bindParam(':attatch2', $attatch2_src); $stmt->bindParam(':attatch2', $attatch2_src);
$stmt->bindParam(':sign_day', $signDay);
$stmt->bindParam(':updated_at', $current_date); $stmt->bindParam(':updated_at', $current_date);
$stmt->execute(); $stmt->execute();

64
wms/cont/js/pricereviewAlpine.js

@ -23,6 +23,7 @@ const pricereviewCreate = ()=>{
pay_method:payment_kind, // 付款方式 pay_method:payment_kind, // 付款方式
startDate:contract_begin_date, //合約開始日期 startDate:contract_begin_date, //合約開始日期
endDate:contract_end_date, // 合約結束日期 endDate:contract_end_date, // 合約結束日期
signDay: signDay, //預計簽約日
brand:brand, brand:brand,
modalElevatorInfo:{ modalElevatorInfo:{
spec:'', spec:'',
@ -91,6 +92,7 @@ const pricereviewCreate = ()=>{
qty:1, //電梯數量 qty:1, //電梯數量
sale_price:'', //契約報價 sale_price:'', //契約報價
inspectionFee:0, inspectionFee:0,
bonus:''
}; };
}, },
createElevatorFn(){ createElevatorFn(){
@ -127,7 +129,8 @@ const pricereviewCreate = ()=>{
price: this.modalElevatorInfo.price, price: this.modalElevatorInfo.price,
qty: this.modalElevatorInfo.qty, qty: this.modalElevatorInfo.qty,
sale_price: this.modalElevatorInfo.sale_price, sale_price: this.modalElevatorInfo.sale_price,
inspectionFee: this.modalElevatorInfo.inspectionFee inspectionFee: this.modalElevatorInfo.inspectionFee,
bonus:''
}) })
this.hideCreateElevatorModal(); this.hideCreateElevatorModal();
}, },
@ -149,6 +152,7 @@ const pricereviewCreate = ()=>{
const qty = this.elevators[idx].qty; const qty = this.elevators[idx].qty;
const sale_price = this.elevators[idx].sale_price; const sale_price = this.elevators[idx].sale_price;
const inspectionFee = this.elevators[idx].inspectionFee; const inspectionFee = this.elevators[idx].inspectionFee;
const bonus = this.elevators[idx].bonus;
this.total_spec ++; this.total_spec ++;
this.elevators.push({ this.elevators.push({
id: this.total_spec, id: this.total_spec,
@ -169,7 +173,8 @@ const pricereviewCreate = ()=>{
price: price, price: price,
qty: qty, qty: qty,
sale_price: sale_price, sale_price: sale_price,
inspectionFee: inspectionFee inspectionFee: inspectionFee,
bonus: bonus
}) })
}, },
removeElevator(id){ removeElevator(id){
@ -365,8 +370,9 @@ const pricereviewCreate = ()=>{
form.append('brand', this.brand); form.append('brand', this.brand);
form.append('num', this.totalElevatorsNum); form.append('num', this.totalElevatorsNum);
form.append('salesman', this.salesman); form.append('salesman', this.salesman);
form.append('contract_begin_date', this.startDate); form.append('signDay', this.startDate);
form.append('contract_end_date', this.endDate); form.append('contract_end_date', this.endDate);
form.append('contract_begin_date', this.signDay);
form.append('contract_kind', this.contract_status); form.append('contract_kind', this.contract_status);
form.append('progress_status', this.progress_status); form.append('progress_status', this.progress_status);
form.append('serviceFee', this.serviceFee); form.append('serviceFee', this.serviceFee);
@ -426,6 +432,7 @@ const pricereviewCreate = ()=>{
if(this.case_name == '') this.error.push("請輸入案件名稱"); if(this.case_name == '') this.error.push("請輸入案件名稱");
if(this.startDate == '' || this.startDate == '0000-00-00') this.error.push("請輸入合約開始日期"); if(this.startDate == '' || this.startDate == '0000-00-00') this.error.push("請輸入合約開始日期");
if(this.endDate == '' ||this.endDate == '0000-00-00') this.error.push("請輸入合約結束日期"); if(this.endDate == '' ||this.endDate == '0000-00-00') this.error.push("請輸入合約結束日期");
if(this.signDay == '' ||this.signDay == '0000-00-00') this.error.push("請輸入預計簽約日期");
if(this.error.length > 0){ if(this.error.length > 0){
let errortext = ''; let errortext = '';
@ -454,6 +461,7 @@ const pricereviewCreate = ()=>{
form.append('salesman', this.salesman); form.append('salesman', this.salesman);
form.append('contract_begin_date', this.startDate); form.append('contract_begin_date', this.startDate);
form.append('contract_end_date', this.endDate); form.append('contract_end_date', this.endDate);
form.append('signDay', this.signDay);
form.append('contract_kind', this.contract_status); form.append('contract_kind', this.contract_status);
form.append('progress_status', this.progress_status); form.append('progress_status', this.progress_status);
form.append('serviceFee', this.serviceFee); form.append('serviceFee', this.serviceFee);
@ -497,7 +505,10 @@ const pricereviewCreate = ()=>{
} }
}, },
async getBonus(idx){ async getBonus(idx){
if(this.contract_status == "") return alert("請選擇契約性質")
let contract_type = ''; let contract_type = '';
let version = '';
let payment_period = '';
if(this.contract_status == 1){ if(this.contract_status == 1){
contract_type = 'new' contract_type = 'new'
}else if(this.contract_status == 2){ }else if(this.contract_status == 2){
@ -505,10 +516,24 @@ const pricereviewCreate = ()=>{
}else if(this.contract_status == 3){ }else if(this.contract_status == 3){
contract_type = 'renew_priceissue' contract_type = 'renew_priceissue'
} }
this.getBonusVersion(this.signDay)
if(this.pay_method == "A40003"){
payment_period = 'monthly'
}else if(this.pay_method == "A40004"){
payment_period = "bimonthly"
}else if(this.pay_method == "A40007"){
payment_period = "quarterly"
}else if(this.pay_method == "A40005"){
payment_period = "semiannually"
}else if(this.pay_method == "A40006"){
payment_period = "annually"
}
const contract_years = this.isDifferenceMoreThanAYear(this.startDate, this.endDate); const contract_years = this.isDifferenceMoreThanAYear(this.startDate, this.endDate);
const receivable_date_due = this.getNext25thDate(this.startDate); const receivable_date_due = this.getNext25thDate(this.startDate);
const res = await axios.get('./api/maintaenance_contract_bonus.php', {params: const res = await axios.get('./api/maintaenance_contract_bonus.php', {params:
{ {
'ver':'2.0',
'contract_type':contract_type, 'contract_type':contract_type,
'contract_years': contract_years, 'contract_years': contract_years,
'discount': this.discountRate, 'discount': this.discountRate,
@ -517,8 +542,9 @@ const pricereviewCreate = ()=>{
'sales_id': user_id, 'sales_id': user_id,
'region_manger_id': 'M0174', 'region_manger_id': 'M0174',
'regular_contract_manger_id': 'M0174', 'regular_contract_manger_id': 'M0174',
'payment_period': payment_period
}}) }})
this.elevators[idx].bonus = Number(res.data.bonus_array[0].bonus_amount)
console.log(res.data); console.log(res.data);
}, },
@ -527,6 +553,12 @@ const pricereviewCreate = ()=>{
const difference = Math.abs(endDate - startDate); const difference = Math.abs(endDate - startDate);
return difference > oneYear ? 'above_two' : 'one'; return difference > oneYear ? 'above_two' : 'one';
}, },
getBonusVersion(dateString) {
const targetDate = new Date('2024-04-01');
const dateToCheck = new Date(dateString);
return dateToCheck > targetDate ? '2.1' : '2.0';
},
getNext25thDate(dateString) { getNext25thDate(dateString) {
// 將傳入的日期字串轉換為 Date 物件 // 將傳入的日期字串轉換為 Date 物件
let date = new Date(dateString); let date = new Date(dateString);
@ -546,7 +578,29 @@ const pricereviewCreate = ()=>{
month = month < 10 ? '0' + month : month; // 確保月份是兩位數 month = month < 10 ? '0' + month : month; // 確保月份是兩位數
return `${year}-${month}-25`; return `${year}-${month}-25`;
} },
generateTestData(){
this.modalElevatorInfo = {
spec:'MAE100',
person:'10',
weight:'700',
stop:'10',
speed:'60',
permitNumber:'TEST', //許可證號碼
brand:'永大', //品牌
m1:'N', //贈送M1
months:12, // 保養月數
cycle:'1', // 保養週期
method:'A', //保養方式
checkYear:'100', //竣工檢查年度
lastDate:'2023-01-01', // 上次年檢日期
yearCheckFee:1260, //年檢費用
price:'4400', //公司發布價(月)
qty:1, //電梯數量
sale_price:'2500', //契約報價
inspectionFee:0, //檢驗費
};
},
} }
} }

19
wms/cont/pricereviewCreate.php

@ -171,7 +171,7 @@ function getApplyKey($p_yyyymm, $seq_name){
<table class="table" border="1"> <table class="table" border="1">
<thead > <thead >
<tr class="" > <tr class="" >
<th scope="col" class="text-center " colspan="10">價格審查(契約)基本資料</th> <th scope="col" class="text-center " colspan="6">價格審查(契約)基本資料</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -204,6 +204,14 @@ function getApplyKey($p_yyyymm, $seq_name){
<input class="form-control" type="text" x-model="case_name" /> <input class="form-control" type="text" x-model="case_name" />
<span class="errortext" x-cloak data-type="errortext" x-show="!case_name">請填寫案件名稱</span> <span class="errortext" x-cloak data-type="errortext" x-show="!case_name">請填寫案件名稱</span>
</td> </td>
</tr>
<tr>
<th>預計簽約日期</th>
<td>
<input type="date" class="form-control" x-model="signDay" />
<span class="errortext" x-cloak data-type="errortext" x-show="!signDay || signDay == '0000-00-00'">請填寫預計簽約日期</span>
</td>
<th>合約開始日期</th> <th>合約開始日期</th>
<td> <td>
<input type="date" class="form-control" x-model="startDate" /> <input type="date" class="form-control" x-model="startDate" />
@ -447,6 +455,14 @@ function getApplyKey($p_yyyymm, $seq_name){
<input type="text" class="form-control" disabled x-model="(elevator.sale_price * elevator.months).toLocaleString()" /> <input type="text" class="form-control" disabled x-model="(elevator.sale_price * elevator.months).toLocaleString()" />
</td> </td>
</tr> </tr>
<tr>
<td>
<button class="btn btn-primary" @click="getBonus(idx)" style="width:100px" x-text="elevator.bonus=='' ? '計算獎金' : '重新計算'"></button>
</td>
<td>
<input type="text" class="form-control" x-model="elevator.bonus.toLocaleString()" disabled />
</td>
</tr>
</tbody> </tbody>
</template> </template>
</table> </table>
@ -606,6 +622,7 @@ function getApplyKey($p_yyyymm, $seq_name){
const case_name = '<?php echo $apply ? $apply['case_name'] : '' ?>'; const case_name = '<?php echo $apply ? $apply['case_name'] : '' ?>';
const contract_begin_date = '<?php echo $apply ? $apply['contract_begin_date'] : '' ?>'; const contract_begin_date = '<?php echo $apply ? $apply['contract_begin_date'] : '' ?>';
const contract_end_date = '<?php echo $apply ? $apply['contract_end_date'] : '' ?>'; const contract_end_date = '<?php echo $apply ? $apply['contract_end_date'] : '' ?>';
const signDay = '<?php echo $apply ? $apply['sign_day'] : '' ?>';
const total_spec = '<?php echo $total_spec; ?>'; const total_spec = '<?php echo $total_spec; ?>';
const hope_elevators = [...<?php echo json_encode($hope_elevators); ?>]; const hope_elevators = [...<?php echo json_encode($hope_elevators); ?>];

0
wms/cont/pricereviewIndex.php

3
wms/cont/window-modal/modalElevaotr.php

@ -173,6 +173,9 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<?php if($user_id === "M0174"): ?>
<button type="button" class="btn btn-success" @click="generateTestData()">測試</button>
<?php endif; ?>
<button type="button" class="btn btn-secondary" @click="hideCreateElevatorModal()">關閉</button> <button type="button" class="btn btn-secondary" @click="hideCreateElevatorModal()">關閉</button>
<button type="button" class="btn btn-primary" @click="createElevatorFn()">新增</button> <button type="button" class="btn btn-primary" @click="createElevatorFn()">新增</button>
</div> </div>

Loading…
Cancel
Save