Commit 223f3a8c authored by 伊藤雄大's avatar 伊藤雄大

2024/07/12

 乗降履歴変更、他
parent e86b0c0f
...@@ -4,6 +4,23 @@ ...@@ -4,6 +4,23 @@
<ion-content [fullscreen]="true"> <ion-content [fullscreen]="true">
<ion-grid style="margin-top:20px;"> <ion-grid style="margin-top:20px;">
<ion-row>
<ion-col class="ion-text-right" style="padding-top:10px;">
<ion-label (click)="onClickBefore()"></ion-label>
</ion-col>
<ion-col>
<ion-datetime-button style="width:160px;" datetime="datetime"></ion-datetime-button>
<ion-modal [keepContentsMounted]="true">
<ng-template>
<ion-datetime id="datetime" presentation="date" [(ngModel)]="searchDate" [showDefaultButtons]="true"
(ionChange)="onChangeDate($event)"></ion-datetime>
</ng-template>
</ion-modal>
</ion-col>
<ion-col style="padding-top:10px;">
<ion-label (click)="onClickAfter()"></ion-label>
</ion-col>
</ion-row>
@for (history of historyList;track history.getonoffDt) { @for (history of historyList;track history.getonoffDt) {
<ion-row> <ion-row>
<ion-col size="auto"> <ion-col size="auto">
......
...@@ -12,6 +12,7 @@ import { HistoryService } from '../services/history.service'; ...@@ -12,6 +12,7 @@ import { HistoryService } from '../services/history.service';
styleUrls: ['./history.page.scss'], styleUrls: ['./history.page.scss'],
}) })
export class HistoryPage implements OnInit { export class HistoryPage implements OnInit {
searchDate?: string;
//乗車履歴 //乗車履歴
historyList?: HistoryModel[]; historyList?: HistoryModel[];
...@@ -27,8 +28,13 @@ export class HistoryPage implements OnInit { ...@@ -27,8 +28,13 @@ export class HistoryPage implements OnInit {
* 初期化 * 初期化
*/ */
ngOnInit() { ngOnInit() {
this.searchDate = (new Date()).toLocaleDateString("ja-JP", {
year: "numeric",
month: "2-digit",
day: "2-digit",
}).split("/").join("-");
if (this.routeService.customerId) { if (this.routeService.customerId) {
this.historyList = this.historyService.getHistoryList(this.routeService.customerId); this.historyList = this.historyService.getHistoryList(this.routeService.customerId, this.searchDate);
} }
} }
...@@ -40,4 +46,50 @@ export class HistoryPage implements OnInit { ...@@ -40,4 +46,50 @@ export class HistoryPage implements OnInit {
this.routeService.navigateMenu(this.routeService.customerId); this.routeService.navigateMenu(this.routeService.customerId);
} }
} }
/**
* 前日へ
*/
onClickBefore() {
if (this.searchDate) {
let date = new Date(this.searchDate);
date.setDate(date.getDate() - 1);
this.searchDate = date.toLocaleDateString("ja-JP", {
year: "numeric",
month: "2-digit",
day: "2-digit",
}).split("/").join("-");
if (this.routeService.customerId) {
this.historyList = this.historyService.getHistoryList(this.routeService.customerId, this.searchDate);
}
}
}
/**
* 翌日へ
*/
onClickAfter() {
if (this.searchDate) {
let date = new Date(this.searchDate);
date.setDate(date.getDate() + 1);
this.searchDate = date.toLocaleDateString("ja-JP", {
year: "numeric",
month: "2-digit",
day: "2-digit",
}).split("/").join("-");
if (this.routeService.customerId) {
this.historyList = this.historyService.getHistoryList(this.routeService.customerId, this.searchDate);
}
}
}
/**
* 日付指定
* @param event イベント情報
*/
onChangeDate(event: any): void {
if (this.routeService.customerId) {
this.historyList = this.historyService.getHistoryList(this.routeService.customerId, event.target.value);
}
}
} }
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
export class CommuterPassModel { export class CommuterPassModel {
//トークンID //トークンID
tokenId?: string; tokenId?: string;
//定期券ID
commuterPassId?: string;
//事業者ID //事業者ID
agencyId: string = ""; agencyId: string = "";
//経路ID //経路ID
......
/**
* 払戻情報
*/
export class RefundModel {
//乗車停留所
getonStopId?: string;
//降車停留所
getoffStopId?: string;
//購入金額
purchaseAmount?: number;
//通常運賃
standardFare?: number;
//使用日数
usedDays?: number;
//払戻手数料
refundFee?: number;
//払戻額
refundAmount?: number;
}
\ No newline at end of file
...@@ -45,9 +45,9 @@ ...@@ -45,9 +45,9 @@
<ion-row> <ion-row>
<ion-col> <ion-col>
<ion-item> <ion-item>
<ion-select label="乗車停留所" [value]="getonStopId"> <ion-select label="乗車停留所" [(ngModel)]="getonStopId" (ionChange)="onChangeGetOn($event)">
@for (kv of stopList|keyvalue;track kv.key) { @for (kv of stopList|keyvalue;track kv.key) {
<ion-select-option value="kv.key">{{kv.value}}</ion-select-option> <ion-select-option [value]="kv.key">{{kv.value}}</ion-select-option>
} }
</ion-select> </ion-select>
</ion-item> </ion-item>
...@@ -56,9 +56,9 @@ ...@@ -56,9 +56,9 @@
<ion-row> <ion-row>
<ion-col> <ion-col>
<ion-item> <ion-item>
<ion-select label="区間" [value]="getoffStopId"> <ion-select label="区間" [(ngModel)]="getoffStopId" (ionChange)="onChangeGetOff($event)">
@for (kv of stopList|keyvalue;track kv.key) { @for (kv of stopList|keyvalue;track kv.key) {
<ion-select-option value="kv.key">{{kv.value}}</ion-select-option> <ion-select-option [value]="kv.key">{{kv.value}}</ion-select-option>
} }
</ion-select> </ion-select>
</ion-item> </ion-item>
...@@ -68,16 +68,16 @@ ...@@ -68,16 +68,16 @@
<ion-col style="margin-left:20px;"> <ion-col style="margin-left:20px;">
<ion-label>購入金額</ion-label> <ion-label>購入金額</ion-label>
</ion-col> </ion-col>
<ion-col class="ion-text-center"> <ion-col class="ion-text-right">
<ion-label>{{purchasePrice|number}}円</ion-label> <ion-label style="margin-right:20px;">{{purchasePrice|number}}円</ion-label>
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row>
<ion-col style="margin-left:20px;"> <ion-col style="margin-left:20px;">
<ion-label>払戻金額</ion-label> <ion-label>払戻金額</ion-label>
</ion-col> </ion-col>
<ion-col class="ion-text-center"> <ion-col class="ion-text-right">
<ion-label>{{refundPrice|number}}円</ion-label> <ion-label style="margin-right:20px;">{{refundPrice|number}}円</ion-label>
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row>
......
...@@ -54,6 +54,10 @@ export class PassChangePage implements OnInit { ...@@ -54,6 +54,10 @@ export class PassChangePage implements OnInit {
//停留所一覧 //停留所一覧
if (this.commuterPassModel) { if (this.commuterPassModel) {
this.stopList = this.passService.getStopList(this.commuterPassModel?.agencyId, this.commuterPassModel?.routeId); this.stopList = this.passService.getStopList(this.commuterPassModel?.agencyId, this.commuterPassModel?.routeId);
this.getonStopId = this.commuterPassModel.getonStopId;
this.getoffStopId = this.commuterPassModel.getoffStopId;
this.purchasePrice = this.passService.calcPassAmount(this.commuterPassModel.agencyId, this.commuterPassModel.routeId, this.commuterPassModel.useTermId, this.commuterPassModel.priceRangeId, this.getonStopId, this.getoffStopId);
this.refundPrice = this.passService.calcRefundAmount(this.commuterPassModel.agencyId, this.commuterPassModel.routeId, this.commuterPassModel.startDate, this.commuterPassModel.useTermId, this.commuterPassModel.priceRangeId, this.commuterPassModel.getonStopId, this.commuterPassModel.getoffStopId, this.purchasePrice);
} }
} }
...@@ -78,4 +82,24 @@ export class PassChangePage implements OnInit { ...@@ -78,4 +82,24 @@ export class PassChangePage implements OnInit {
} }
this.routeService.navigatePassSelect(this.cardNumber); this.routeService.navigatePassSelect(this.cardNumber);
} }
/**
* 乗車停留所選択
* @param event イベント情報
*/
onChangeGetOn(event: any): void {
if (this.commuterPassModel) {
this.purchasePrice = this.passService.calcPassAmount(this.commuterPassModel.agencyId, this.commuterPassModel.routeId, this.commuterPassModel.useTermId, this.commuterPassModel.priceRangeId, event.target.value, this.getoffStopId);
}
}
/**
* 降車停留所選択
* @param event イベント情報
*/
onChangeGetOff(event: any): void {
if (this.commuterPassModel) {
this.purchasePrice = this.passService.calcPassAmount(this.commuterPassModel.agencyId, this.commuterPassModel.routeId, this.commuterPassModel.useTermId, this.commuterPassModel.priceRangeId, this.getonStopId, event.target.value);
}
}
} }
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
<ion-row> <ion-row>
<ion-col> <ion-col>
<ion-item> <ion-item>
<ion-select label="使用期間" [value]="useTermId"> <ion-select label="使用期間" [(ngModel)]="useTermId" (ionChange)="onChangeTerm($event)">
@for (kv of useTermList|keyvalue;track kv.key) { @for (kv of useTermList|keyvalue;track kv.key) {
<ion-select-option value="kv.key">{{kv.value}}</ion-select-option> <ion-select-option [value]="kv.key">{{kv.value}}</ion-select-option>
} }
</ion-select> </ion-select>
</ion-item> </ion-item>
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<ion-datetime-button datetime="datetime"></ion-datetime-button> <ion-datetime-button datetime="datetime"></ion-datetime-button>
<ion-modal [keepContentsMounted]="true"> <ion-modal [keepContentsMounted]="true">
<ng-template> <ng-template>
<ion-datetime id="datetime" presentation="date" [value]="startDate"></ion-datetime> <ion-datetime id="datetime" presentation="date" [(ngModel)]="startDate"></ion-datetime>
</ng-template> </ng-template>
</ion-modal> </ion-modal>
</ion-col> </ion-col>
......
...@@ -52,6 +52,8 @@ export class PassContinuePage implements OnInit { ...@@ -52,6 +52,8 @@ export class PassContinuePage implements OnInit {
//使用期間一覧 //使用期間一覧
if (this.commuterPassModel) { if (this.commuterPassModel) {
this.useTermList = this.passService.getUseTermList(this.commuterPassModel?.agencyId); this.useTermList = this.passService.getUseTermList(this.commuterPassModel?.agencyId);
this.useTermId = this.commuterPassModel.useTermId;
this.price = this.passService.calcPassAmount(this.commuterPassModel.agencyId, this.commuterPassModel.routeId, this.useTermId, this.commuterPassModel.priceRangeId, this.commuterPassModel.getonStopId, this.commuterPassModel.getoffStopId);
} }
} }
...@@ -76,4 +78,14 @@ export class PassContinuePage implements OnInit { ...@@ -76,4 +78,14 @@ export class PassContinuePage implements OnInit {
} }
this.routeService.navigatePassSelect(this.cardNumber); this.routeService.navigatePassSelect(this.cardNumber);
} }
/**
* 使用期間選択
* @param event イベント情報
*/
onChangeTerm(event: any): void {
if (this.commuterPassModel) {
this.price = this.passService.calcPassAmount(this.commuterPassModel.agencyId, this.commuterPassModel.routeId, event.target.value, this.commuterPassModel.priceRangeId, this.commuterPassModel.getonStopId, this.commuterPassModel.getoffStopId);
}
}
} }
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<ion-label>購入金額</ion-label> <ion-label>購入金額</ion-label>
</ion-col> </ion-col>
<ion-col class="ion-text-right" style="margin-right:20px;"> <ion-col class="ion-text-right" style="margin-right:20px;">
<ion-label>{{purchasePrice|number}}円</ion-label> <ion-label>{{purchaseAmount|number}}円</ion-label>
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row>
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<ion-label>普通運賃</ion-label> <ion-label>普通運賃</ion-label>
</ion-col> </ion-col>
<ion-col class="ion-text-right" style="margin-right:20px;"> <ion-col class="ion-text-right" style="margin-right:20px;">
<ion-label>{{normalFare|number}}円</ion-label> <ion-label>{{standardFare|number}}円</ion-label>
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row>
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<ion-label>使用日数</ion-label> <ion-label>使用日数</ion-label>
</ion-col> </ion-col>
<ion-col class="ion-text-right" style="margin-right:20px;"> <ion-col class="ion-text-right" style="margin-right:20px;">
<ion-label>{{useDays}}日</ion-label> <ion-label>{{usedDays}}日</ion-label>
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<ion-label>払戻金額</ion-label> <ion-label>払戻金額</ion-label>
</ion-col> </ion-col>
<ion-col class="ion-text-right" style="margin-right:20px;"> <ion-col class="ion-text-right" style="margin-right:20px;">
<ion-label>{{refundPrice|number}}円</ion-label> <ion-label>{{refundAmount|number}}円</ion-label>
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row>
......
...@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core'; ...@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { CommuterPassModel } from '../model/commuter-pass.model'; import { CommuterPassModel } from '../model/commuter-pass.model';
import { RouteService } from '../services/route.service'; import { RouteService } from '../services/route.service';
import { PassService } from '../services/pass.service'; import { PassService } from '../services/pass.service';
import { RefundModel } from '../model/refund.model';
/** /**
* 定期券払戻画面 * 定期券払戻画面
...@@ -27,15 +28,15 @@ export class PassRefundPage implements OnInit { ...@@ -27,15 +28,15 @@ export class PassRefundPage implements OnInit {
//定期券情報 //定期券情報
commuterPassModel?: CommuterPassModel; commuterPassModel?: CommuterPassModel;
//購入金額 //購入金額
purchasePrice: number = 0; purchaseAmount: number = 0;
//普通運賃 //普通運賃
normalFare: number = 0; standardFare: number = 0;
//使用日数 //使用日数
useDays: number = 0; usedDays: number = 0;
//払戻手数料 //払戻手数料
refundFee: number = 0; refundFee: number = 0;
//払戻金額 //払戻金額
refundPrice: number = 0; refundAmount: number = 0;
/** /**
* コンストラクタ * コンストラクタ
...@@ -51,11 +52,14 @@ export class PassRefundPage implements OnInit { ...@@ -51,11 +52,14 @@ export class PassRefundPage implements OnInit {
* 初期化 * 初期化
*/ */
ngOnInit(): void { ngOnInit(): void {
this.purchasePrice = 40000; if (this.commuterPassModel && this.commuterPassModel.commuterPassId) {
this.normalFare = 200; let model: RefundModel = this.passService.getRefund(this.commuterPassModel.commuterPassId);
this.useDays = 30; this.purchaseAmount = model.purchaseAmount ? model.purchaseAmount : 0;
this.refundFee = 500; this.standardFare = model.standardFare ? model.standardFare : 0;
this.refundPrice = 10500; this.usedDays = model.usedDays ? model.usedDays : 0;
this.refundFee = model.refundFee ? model.refundFee : 0;
this.refundAmount = model.refundAmount ? model.refundAmount : 0;
}
} }
/** /**
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
<ion-row> <ion-row>
<ion-col> <ion-col>
<ion-item> <ion-item>
<ion-select label="路線" [value]="routeId" (change)="onChangeRoute($event)"> <ion-select label="路線" [(ngModel)]="routeId" (ionChange)="onChangeRoute($event)">
@for (kv of routeList|keyvalue;track kv.key) { @for (kv of routeList|keyvalue;track kv.key) {
<ion-select-option value="kv.key">{{kv.value}}</ion-select-option> <ion-select-option [value]="kv.key">{{kv.value}}</ion-select-option>
} }
</ion-select> </ion-select>
</ion-item> </ion-item>
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
<ion-row> <ion-row>
<ion-col> <ion-col>
<ion-item> <ion-item>
<ion-select label="使用期間" [value]="useTermId"> <ion-select label="使用期間" [(ngModel)]="useTermId" (ionChange)="onChangeTerm($event)">
@for (kv of useTermList|keyvalue;track kv.key) { @for (kv of useTermList|keyvalue;track kv.key) {
<ion-select-option value="kv.key">{{kv.value}}</ion-select-option> <ion-select-option [value]="kv.key">{{kv.value}}</ion-select-option>
} }
</ion-select> </ion-select>
</ion-item> </ion-item>
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
<ion-row> <ion-row>
<ion-col> <ion-col>
<ion-item> <ion-item>
<ion-select label="料金区分" [value]="priceRangeId"> <ion-select label="料金区分" [(ngModel)]="priceRangeId" (ionChange)="onChangeRange($event)">
@for (kv of priceRangeList|keyvalue;track kv.key) { @for (kv of priceRangeList|keyvalue;track kv.key) {
<ion-select-option value="kv.key">{{kv.value}}</ion-select-option> <ion-select-option [value]="kv.key">{{kv.value}}</ion-select-option>
} }
</ion-select> </ion-select>
</ion-item> </ion-item>
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<ion-datetime-button datetime="datetime"></ion-datetime-button> <ion-datetime-button datetime="datetime"></ion-datetime-button>
<ion-modal [keepContentsMounted]="true"> <ion-modal [keepContentsMounted]="true">
<ng-template> <ng-template>
<ion-datetime id="datetime" presentation="date" [value]="startDate"></ion-datetime> <ion-datetime id="datetime" presentation="date" [(ngModel)]="startDate"></ion-datetime>
</ng-template> </ng-template>
</ion-modal> </ion-modal>
</ion-col> </ion-col>
...@@ -53,9 +53,9 @@ ...@@ -53,9 +53,9 @@
<ion-row> <ion-row>
<ion-col> <ion-col>
<ion-item> <ion-item>
<ion-select label="乗車停留所" [value]="getonStopId"> <ion-select label="乗車停留所" [(ngModel)]="getonStopId" (ionChange)="onChangeGetOn($event)">
@for (kv of stopList|keyvalue;track kv.key) { @for (kv of stopList|keyvalue;track kv.key) {
<ion-select-option value="kv.key">{{kv.value}}</ion-select-option> <ion-select-option [value]="kv.key">{{kv.value}}</ion-select-option>
} }
</ion-select> </ion-select>
</ion-item> </ion-item>
...@@ -64,20 +64,20 @@ ...@@ -64,20 +64,20 @@
<ion-row> <ion-row>
<ion-col> <ion-col>
<ion-item> <ion-item>
<ion-select label="区間" [value]="getoffStopId"> <ion-select label="区間" [(ngModel)]="getoffStopId" (ionChange)="onChangeGetOff($event)">
@for (kv of stopList|keyvalue;track kv.key) { @for (kv of stopList|keyvalue;track kv.key) {
<ion-select-option value="kv.key">{{kv.value}}</ion-select-option> <ion-select-option [value]="kv.key">{{kv.value}}</ion-select-option>
} }
</ion-select> </ion-select>
</ion-item> </ion-item>
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row>
<ion-col class="ion-text-center"> <ion-col>
<ion-label>支払金額</ion-label> <ion-label style="margin-left:16px;">支払金額</ion-label>
</ion-col> </ion-col>
<ion-col class="ion-text-center"> <ion-col class="ion-text-right">
<ion-label>{{price|number}}円</ion-label> <ion-label style="margin-right:20px;">{{price|number}}円</ion-label>
</ion-col> </ion-col>
</ion-row> </ion-row>
<ion-row> <ion-row>
......
import { KeyValue } from '@angular/common';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { RouteService } from '../services/route.service'; import { RouteService } from '../services/route.service';
import { CommuterPassModel } from '../model/commuter-pass.model'; import { CommuterPassModel } from '../model/commuter-pass.model';
...@@ -66,15 +65,20 @@ export class PassRegistPage implements OnInit { ...@@ -66,15 +65,20 @@ export class PassRegistPage implements OnInit {
//路線一覧 //路線一覧
//TODO 事業者IDはどうやって決める? //TODO 事業者IDはどうやって決める?
this.routeList = this.passService.getRouteList(this.agencyId); this.routeList = this.passService.getRouteList(this.agencyId);
this.routeId = this.routeList.keys().next().value;
//使用期間一覧 //使用期間一覧
this.useTermList = this.passService.getUseTermList(this.agencyId); this.useTermList = this.passService.getUseTermList(this.agencyId);
this.useTermId = this.useTermList.keys().next().value;
//料金区分一覧 //料金区分一覧
this.priceRangeList = this.passService.getPriceRangeList(this.agencyId); this.priceRangeList = this.passService.getPriceRangeList(this.agencyId);
this.priceRangeId = this.priceRangeList.keys().next().value;
//停留所一覧 //停留所一覧
this.stopList = this.passService.getStopList(this.agencyId, this.routeList.values().next().value); this.stopList = this.passService.getStopList(this.agencyId, this.routeList.values().next().value);
this.getonStopId = this.stopList.keys().next().value;
this.getoffStopId = this.stopList.keys().next().value;
} }
/** /**
...@@ -83,6 +87,39 @@ export class PassRegistPage implements OnInit { ...@@ -83,6 +87,39 @@ export class PassRegistPage implements OnInit {
*/ */
onChangeRoute(event: any): void { onChangeRoute(event: any): void {
this.stopList = this.passService.getStopList(this.agencyId, event.target.value); this.stopList = this.passService.getStopList(this.agencyId, event.target.value);
this.price = this.passService.calcPassAmount(this.agencyId, event.target.value, this.useTermId, this.priceRangeId, this.getonStopId, this.getoffStopId);
}
/**
* 使用期間選択
* @param event イベント情報
*/
onChangeTerm(event: any): void {
this.price = this.passService.calcPassAmount(this.agencyId, this.routeId, event.target.value, this.priceRangeId, this.getonStopId, this.getoffStopId);
}
/**
* 料金区分選択
* @param event イベント情報
*/
onChangeRange(event: any): void {
this.price = this.passService.calcPassAmount(this.agencyId, this.routeId, this.useTermId, event.target.value, this.getonStopId, this.getoffStopId);
}
/**
* 乗車停留所選択
* @param event イベント情報
*/
onChangeGetOn(event: any): void {
this.price = this.passService.calcPassAmount(this.agencyId, this.routeId, this.useTermId, this.priceRangeId, event.target.value, this.getoffStopId);
}
/**
* 降車停留所選択
* @param event イベント情報
*/
onChangeGetOff(event: any): void {
this.price = this.passService.calcPassAmount(this.agencyId, this.routeId, this.useTermId, this.priceRangeId, this.getonStopId, event.target.value);
} }
/** /**
......
...@@ -16,15 +16,21 @@ export class HistoryService { ...@@ -16,15 +16,21 @@ export class HistoryService {
/** /**
* 乗降履歴一覧取得 * 乗降履歴一覧取得
* @param customerId 利用者ID * @param customerId 利用者ID
* @param searchDate 検索対象日
* @returns 乗降履歴一覧 * @returns 乗降履歴一覧
*/ */
getHistoryList(customerId: string): HistoryModel[] { getHistoryList(customerId: string, searchDate?: string): HistoryModel[] {
//TODO //TODO
let historyList = new Array(); let historyList = new Array();
for (let i = 0; i < 10; i++) { for (let i = 0; i < 10; i++) {
let historyModel: HistoryModel = new HistoryModel(); let historyModel: HistoryModel = new HistoryModel();
let str = String(i); let str = String(i);
historyModel.getonoffDt = "2024/06/19 17:08:1" + str; if (searchDate) {
let ymd: string[] = searchDate?.split("-");
historyModel.getonoffDt = ymd[0] + "/" + ymd[1] + "/" + ymd[2] + " 17:08:1" + str;
} else {
historyModel.getonoffDt = "2024/07/01 17:08:1" + str;
}
historyModel.stopId = str; historyModel.stopId = str;
if (i % 2 == 0) { if (i % 2 == 0) {
historyModel.kind = "1"; historyModel.kind = "1";
...@@ -39,7 +45,12 @@ export class HistoryService { ...@@ -39,7 +45,12 @@ export class HistoryService {
historyList.push(historyModel); historyList.push(historyModel);
} }
let historyModel: HistoryModel = new HistoryModel(); let historyModel: HistoryModel = new HistoryModel();
historyModel.getonoffDt = "2024/06/19 17:10:10"; if (searchDate) {
let ymd: string[] = searchDate?.split("-");
historyModel.getonoffDt = ymd[0] + "/" + ymd[1] + "/" + ymd[2] + " 17:10:10";
} else {
historyModel.getonoffDt = "2024/07/01 17:10:10";
}
historyModel.kind = "1"; historyModel.kind = "1";
historyModel.stopName = "XXXX停留所"; historyModel.stopName = "XXXX停留所";
historyModel.status = 0; historyModel.status = 0;
......
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { CommuterPassModel } from '../model/commuter-pass.model'; import { CommuterPassModel } from '../model/commuter-pass.model';
import { RefundModel } from '../model/refund.model';
/** /**
* 定期券サービス * 定期券サービス
...@@ -21,15 +22,19 @@ export class PassService { ...@@ -21,15 +22,19 @@ export class PassService {
let commuterPassList = new Array(); let commuterPassList = new Array();
for (let i = 0; i < 2; i++) { for (let i = 0; i < 2; i++) {
let model: CommuterPassModel = new CommuterPassModel(); let model: CommuterPassModel = new CommuterPassModel();
model.tokenId = tokenId;
model.commuterPassId = String(i + 1);
model.routeId = "00000" + String(i); model.routeId = "00000" + String(i);
model.routeName = "【◯◯◯系統】XXXXX→XXXXX行き"; model.routeName = "【◯◯◯系統】XXXXX→XXXXX行き";
model.startDate = "2024/07/01"; model.startDate = "2024/07/01";
model.useTermId = "2"; model.useTermId = "3";
model.useTermName = "3ヶ月"; model.useTermName = "3ヶ月";
model.priceRangeId = "0"; model.priceRangeId = "1";
model.privateRangeName = "大人"; model.privateRangeName = "大人";
model.getonStopName = "XXXXX"; model.getonStopId = "1";
model.getoffStopName = "XXXXX"; model.getonStopName = "停留所1";
model.getoffStopId = "5";
model.getoffStopName = "停留所5";
commuterPassList.push(model); commuterPassList.push(model);
} }
return commuterPassList; return commuterPassList;
...@@ -90,7 +95,7 @@ export class PassService { ...@@ -90,7 +95,7 @@ export class PassService {
getUseTermList(agencyId: string): Map<string, string> { getUseTermList(agencyId: string): Map<string, string> {
let useTermList = new Map(); let useTermList = new Map();
useTermList.set("1", "1ヶ月"); useTermList.set("1", "1ヶ月");
useTermList.set("2", "3ヶ月"); useTermList.set("3", "3ヶ月");
useTermList.set("6", "6ヶ月"); useTermList.set("6", "6ヶ月");
return useTermList; return useTermList;
...@@ -123,4 +128,131 @@ export class PassService { ...@@ -123,4 +128,131 @@ export class PassService {
} }
return stopList; return stopList;
} }
/**
* 定期券料金計算
*
* @param agencyId 事業者ID
* @param routeId 路線ID
* @param useTermId 使用期間
* @param priceRangeId 料金区分
* @param getonStopId 乗車停留所
* @param getoffStopId 降車停留所
*/
calcPassAmount(agencyId: string, routeId?: string, useTermId?: string, priceRangeId?: string, getonStopId?: string, getoffStopId?: string): number {
//TODO
//以下はダミー
//通常運賃
let getonStop = Number(getonStopId);
let getoffStop = Number(getoffStopId);
let unit = (getoffStop - getonStop) >= 0 ? (getoffStop - getonStop) : (getonStop - getoffStop);
unit = unit * 100;
let one = unit * 30 * 0.75;
let three = one * 3 * 0.95;
let six = one * 6 * 0.9;
let ret = 0;
if (useTermId == "1") {
ret = one;
} else if (useTermId == "2") {
ret = three;
} else {
ret = six;
}
if (priceRangeId == "2") {
ret = ret * 0.5;
} else if (priceRangeId == "3") {
ret = ret * 0.6;
}
return Math.floor(ret);
}
/**
* 定期券払戻料金計算
* @param agencyId 事業者ID
* @param routeId 路線ID
* @param startDate 使用開始日
* @param useTermId 使用期間
* @param priceRangeId 料金区分
* @param getonStopId 乗車停留所ID
* @param getoffStopId 降車停留所ID
*/
calcRefundAmount(agencyId: string, routeId?: string, startDate?: string, useTermId?: string, priceRangeId?: string, getonStopId?: string, getoffStopId?: string, purchaseAmount?: number): number {
//TODO
//以下はダミー
//通常運賃
let getonStop = Number(getonStopId);
let getoffStop = Number(getoffStopId);
let unit = (getoffStop - getonStop) >= 0 ? (getoffStop - getonStop) : (getonStop - getoffStop);
unit = unit * 100;
if (priceRangeId == "2") {
unit = unit * 0.5;
} else if (priceRangeId == "3") {
unit = unit * 0.6;
}
//残日数計算
let termDay = 0;
let now = new Date();
if (startDate) {
let start = new Date(startDate);
termDay = (now.getTime() - start.getTime()) / 86400000;
}
if (useTermId == "1") {
termDay = 30 - termDay;
} else if (useTermId == "3") {
termDay = 90 - termDay;
} else if (useTermId == "6") {
termDay = 180 - termDay;
}
let amount = 0;
if (purchaseAmount) {
amount = purchaseAmount - (termDay * unit) - 500;
}
amount = amount < 0 ? 0 : amount;
return Math.floor(amount);
}
/**
* 払戻情報取得
* @param commuterPassId 定期券ID
*/
getRefund(commuterPassId: string): RefundModel {
//TODO
//↓以下はダミー
let ret = new RefundModel();
ret.purchaseAmount = this.calcPassAmount("", "", "3", "1", "1", "5");
//通常運賃
let getonStop = 1;
let getoffStop = 5;
let unit = (getoffStop - getonStop) >= 0 ? (getoffStop - getonStop) : (getonStop - getoffStop);
ret.standardFare = unit * 100;
//使用日数計算
let now = new Date();
let start = new Date("2024/07/01");
ret.usedDays = Math.floor((now.getTime() - start.getTime()) / 86400000);
//残日数
let termDay = 90 - ret.usedDays;
//払戻手数料
ret.refundFee = 500;
let amount = ret.purchaseAmount - (termDay * ret.standardFare) - ret.refundFee;
amount = amount < 0 ? 0 : amount;
ret.refundAmount = Math.floor(amount);
return ret;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment