Commit 074ffde2 authored by 李尚科's avatar 李尚科

Fix

parent 366c051a
Pipeline #13719 passed with stage
in 26 seconds
......@@ -10,6 +10,7 @@ module.exports = app => {
primaryKey: true,
autoIncrement: true
},
order_id: INTEGER,
name: STRING,
phone: STRING,
id_card: STRING,
......
......@@ -68,6 +68,10 @@ class OrderService extends Service {
const expire_time = moment(created_at).valueOf() + 24 * 3600 * 1000;
const now_time = moment().valueOf();
const state_time = moment().format('YYYY-MM-DD HH:mm:ss');
// await this.logOrder(order);
// if (state === '支付中' && pay_status === 0 && moment(order.state_time).valueOf() * 300 < now_time) {
// await ctx.prometheusModel.CreditOrder.update({ state: '待支付', state_time: state_time }, { where: { id } });
// }
if (expire_time < now_time && (state === '待支付' || state === '已取消') && pay_status === 0) {
const ret = await ctx.prometheusModel.CreditOrder.update({ state: '已失效', state_time: state_time }, { where: { id } });
if (ret && ret[0]) {
......@@ -120,11 +124,11 @@ class OrderService extends Service {
if (preferential && preferential.id) {
preferential_price = preferential.price;
}
const price = order.price - preferential_price;
const price = (order.price - preferential_price).toFixed(2);
await ctx.prometheusModel.CreditOrder.update({ price, preferential_price, preferential_id: preferential.id }, { where: { id, pay_status: 0 } });
await ctx.prometheusModel.CreditOrder.update({ final_price: price, preferential_price, preferential_id: preferential.id }, { where: { id, pay_status: 0 } });
return true;
return price;
}
......@@ -201,12 +205,10 @@ class OrderService extends Service {
preferential_price = preferential.price;
preferential_title = preferential.title;
}
const price = order.price - preferential_price;
await ctx.prometheusModel.CreditOrder.update({ price, preferential_price, preferential_id: preferential.id }, { where: { id: order.id, pay_status: 0 } });
const price = await this.updateOrderPrice(order);
const type = order.type;
const countdown = moment(order.state_time).format('X') + 86400 - moment().format('X');
const countdown = moment(order.state_time).format('X') - moment(new Date()).format('X') + 86400;
const ret = {
price,
original_price: order.price,
......@@ -285,7 +287,7 @@ class OrderService extends Service {
if (order && order.pay_status === 1) {
ctx.failed('订单已支付无需重复支付');
}
const price = order.price * 100 - order.preferential_price * 100;
const price = (order.price - order.preferential_price).toFixed(2) * 100;
if (price <= 0) {
ctx.failed('error price');
......@@ -321,7 +323,8 @@ class OrderService extends Service {
await this.updateOrderStateToCancel(order);//更新其他同姓名和身份证号的订单状态
await this.updateOrderPrice(order);//更新金额
await this.logOrder(order);//订单状态变化日志记录
await ctx.prometheusModel.CreditOrder.update({ method: type, state: '支付中' }, { where: { id: order.id } });//更新状态
const state_time = moment().format('YYYY-MM-DD HH:mm:ss');
await ctx.prometheusModel.CreditOrder.update({ pay_method: type }, { where: { id: order.id } });//更新状态
return { url: ret.mweb_url, order_id: order_id, trade_no: data.trade_no };
} else if (type === 'alipay') {
......
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