Commit 589d067a authored by 李尚科's avatar 李尚科

add order

parent 131655bb
Pipeline #13456 passed with stage
in 4 seconds
'use strict';
const Controller = require('egg').Controller;
class OrderController extends Controller {
/**
* 我的信用首页
*/
async getMyCredit() {
const { ctx } = this;
ctx.success(ret);
}
//我的历史首页
async getRecord() {
const { ctx } = this;
const type = ctx.params.type;
const results = await ctx.service.credit.order.getHistoryOrders(type);
ctx.success({ results });
}
}
module.exports = OrderController;
'use strict';
const Service = require('egg').Service;
const moment = require('moment');
const _ = require('lodash');
class OrderService extends Service {
//历史订单
async getHistoryOrders(order_type) {
const { ctx } = this;
const type_obj = {
'blacklist': 1,
'callrisk': 2,
}
const type = type_obj[order_type];
const order_records = await ctx.prometheusModel.CreditOrder.all({ where: { type } });
const worth_h = [];
const worth_l = [];
const worth_time = type === 1 ? 15 : 30;
const now_time = moment().format('X');
for (let i in order_records) {
const order = order_records[i];
const expire_time = moment(state_time).format('X') + worth_time * 86400;
const apply = { phone: '15968762898', report_no: '51gjj201909050100001' };
const item = {
order_no: order.order_no,
report_no: apply.report_no,
type: order_type,
created_time,
phone: apply.phone.replace(apply.phone.substring(3, 7), "****"),
state: order.state,
state_text: order.state === '已支付' ? '' : order.state,
};
if (order.pay_status === 1 && order.state === '已支付' && expire_time > now_time) {
worth_h.push(item);
} else {
worth_l.push(item);
}
}
return { worth_h, worth_l }
}
}
module.exports = OrderService;
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