Commit 57671f14 authored by 姜登's avatar 姜登

uuid

parent 3b31375e
Pipeline #4126 passed with stage
in 46 seconds
......@@ -47,39 +47,29 @@ class OrderController extends Controller {
async create() {
const { ctx, service } = this;
const uuid = require('node-uuid');
ctx.validate(this.createRule);
let { appKey, userId, notifyUrl, backUrl, orderId } = ctx.request.body;
const appKeyInfo = await service.partner.fetchInfo(appKey);
if (!(appKeyInfo && appKeyInfo.valid === true && appKeyInfo.enableHf === true)) {
return ctx.fail('未开通此服务');
}
if (orderId) {
await service.order.update({
orderId,
taskId: '',
userId: userId || '',
cityId: '',
notifyUrl: (ctx.app.notifyMap.get(appKey) && ctx.app.notifyMap.get(appKey).notifyUrl) || '',
backUrl: backUrl || '',
appKey: appKey,
status: 'init',
})
ctx.success({ orderId });
return
}
orderId = uuid.v1();
await service.order.create({
const object = {
orderId,
taskId: '',
userId: userId || '',
cityId: '',
notifyUrl: notifyUrl || '',
notifyUrl: notifyUrl || (ctx.app.notifyMap.get(appKey) && ctx.app.notifyMap.get(appKey).notifyUrl) || '',
backUrl: backUrl || '',
appKey: appKey,
status: 'init',
});
ctx.success({ orderId });
}
if (orderId) {
await service.order.update(object);
} else {
object.orderId = ctx.helper.getUuid();
await service.order.create(object);
}
ctx.success({ orderId: object.orderId });
}
async show() {
......
'use strict';
const querystring = require('querystring');
const crypto = require('crypto');
const uuid = require('uuid/v1');
function process(params) {
const keys = Object.keys(params)
......@@ -57,3 +58,7 @@ module.exports.paramSign = function(appSecret, params) {
.toUpperCase();
return signStr;
};
module.exports.getUuid = function() {
return uuid();
};
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