first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,102 @@
const _ = require("../import");
/**
* @api {post} /order/allOrder allOrder
* @apiDescription 获取不同状态的订单
* @apiName allOrder
* @apiGroup order
* @apiParam {string} status 查询的订单状态0待付款1待发货2待收货3退款/售后,-1查看所有订单
* @apiSuccessExample {json} 请求成功的返回:
* {
* "status" : 200,
* "message" : "请求成功"
* "result" : "asjXzXxmnSp8TZGWiTSlJF8Gb...5LhYoHs86SEI2LBXrTZ9e/a4frZOWHZ"
* }
* @apiErrorExample {json} 请求失败的返回
* {
* "status": 404,
* "message" : "请求失败"
* "result": null
* }
* @apiSampleRequest http://127.0.0.1:9090/order/allOrder
* @apiVersion 1.0.0
*/
_.router.post('/allOrder', async function(req, res, next) {
var status = req.headers.data.status, sql = null, params = [];
if (status == -1) {
sql = _.config.sql.getAllOrder
params = [ _.jwt.decode(req.headers.token).id ]
} else {
sql = _.config.sql.getStatusOrder
params = [ _.jwt.decode(req.headers.token).id, status]
}
var allOrder = await _.db.query({
sql: sql,
data: params
});
if(allOrder.length != 0) {
res.json({
status: 200,
message: '请求成功',
result: _.rsa.PrivateKeyEncryption(allOrder)
});
} else {
res.json({
status: 200,
message: '没有订单',
result: _.rsa.PrivateKeyEncryption({})
});
}
});
/**
* @api {post} /order/buyOrder buyOrder
* @apiDescription submitCar提交订单后订单页面购买支付后需要用的接口更改订单状态为待发货
* @apiName buyOrder
* @apiGroup order
* @apiParam {Array} goodsid 订单的goods_id从allOrder接口中获得。参数格式"[5,6]"
* @apiSuccessExample {json} 请求成功的返回:
* {
* "status" : 200,
* "message" : "购买成功"
* "result" : "asjXzXxmnSp8TZGWiTSlJF8Gb...5LhYoHs86SEI2LBXrTZ9e/a4frZOWHZ"
* }
* @apiErrorExample {json} 请求失败的返回
* {
* "status": 404,
* "message" : "购买失败,余额不足"
* "result": null
* }
* @apiSampleRequest http://127.0.0.1:9090/order/buyOrder
* @apiVersion 1.0.0
*/
_.router.post('/buyOrder', async function(req, res, next) {
var goods_id = JSON.parse(req.headers.data.goodsid);
goods_id.forEach(async function(val) {
var buyOrder = await _.db.query({
sql: _.config.sql.buyOrder,
data: [ 1, val ]
});
});
res.json({
status: 200,
message: '购买成功',
result: _.rsa.PrivateKeyEncryption({})
});
});
module.exports = _.router;