feat: 新增自定义单程票价、站点名称展示及中文事件类型支持
后端调整:支持单程订单使用客户端传入的自定义票价,无需通过系统自动计算 前端优化:新增中文事件类型支持,添加站点编码转中文名称功能,更新日志展示站点中文名称,自动拉取站点列表构建解析映射
This commit is contained in:
+13
-3
@@ -257,9 +257,19 @@ router.post('/orders', async (req, res) => {
|
||||
return res.status(400).json({ ok: false, error: 'missing start/terminal/ride_date' });
|
||||
}
|
||||
const resolveStation = buildStationResolver();
|
||||
const fromCode = resolveStation(from);
|
||||
const toCode = resolveStation(to);
|
||||
const priceSingle = LogicService.computePrice(fromCode, toCode, type);
|
||||
let fromCode = resolveStation(from);
|
||||
let toCode = resolveStation(to);
|
||||
|
||||
let priceSingle = 0;
|
||||
if (type === 'single') {
|
||||
priceSingle = Math.max(0, Number(req.body.price) || 0);
|
||||
// keep from and to as whatever string was passed (e.g. line and fare)
|
||||
fromCode = from;
|
||||
toCode = to;
|
||||
} else {
|
||||
priceSingle = LogicService.computePrice(fromCode, toCode, type);
|
||||
}
|
||||
|
||||
const price = Math.max(0, priceSingle * t);
|
||||
const code = LogicService.genVoucherCode();
|
||||
const rec = { code, start: fromCode, terminal: toCode, train_type: type, trips: t, ride_date: date, price, created_ts: Date.now(), consumed: false };
|
||||
|
||||
Reference in New Issue
Block a user