feat: 已实现订单基本逻辑,到完成,却订单售后
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import type { Context } from '../utils/handler.js'
|
||||
import { guardMethod } from '../utils/method.js'
|
||||
import { readJson } from '../utils/request.js'
|
||||
import { withErrorBoundary } from '../utils/handler.js'
|
||||
import {
|
||||
addressService,
|
||||
type AddressDefaultInput,
|
||||
type AddressDeleteInput,
|
||||
type AddressListInput,
|
||||
type AddressSaveInput
|
||||
} from '../services/address.service.js'
|
||||
import { toHttpResponse } from './controller-response.js'
|
||||
|
||||
export const addressListController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await addressService.list(await readJson<AddressListInput>(request)))
|
||||
})
|
||||
|
||||
export const addressDefaultController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await addressService.default(await readJson<AddressDefaultInput>(request)))
|
||||
})
|
||||
|
||||
export const addressSaveController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await addressService.save(await readJson<AddressSaveInput>(request)))
|
||||
})
|
||||
|
||||
export const addressDeleteController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await addressService.delete(await readJson<AddressDeleteInput>(request)))
|
||||
})
|
||||
@@ -2,6 +2,13 @@ import type { Context } from '../utils/handler.js'
|
||||
import { guardMethod } from '../utils/method.js'
|
||||
import { readJson } from '../utils/request.js'
|
||||
import { withErrorBoundary } from '../utils/handler.js'
|
||||
import {
|
||||
afterSaleService,
|
||||
type AfterSaleApplyInput,
|
||||
type AfterSaleAuditInput,
|
||||
type AfterSaleListInput,
|
||||
type AfterSaleLogisticsInput
|
||||
} from '../services/after-sale.service.js'
|
||||
import { orderActionService } from '../services/order-action.service.js'
|
||||
import { orderCreateService, type CheckoutGoods } from '../services/order-create.service.js'
|
||||
import { orderListService } from '../services/order-list.service.js'
|
||||
@@ -12,6 +19,8 @@ import { toHttpResponse } from './controller-response.js'
|
||||
type OrderListRequest = {
|
||||
supplierId?: string
|
||||
userId?: string
|
||||
orderId?: string
|
||||
mainOrderId?: string
|
||||
}
|
||||
|
||||
type OrderActionRequest = {
|
||||
@@ -19,6 +28,9 @@ type OrderActionRequest = {
|
||||
userId?: string
|
||||
orderId?: string
|
||||
mainOrderId?: string
|
||||
deliveryStatus?: number
|
||||
logisticsOrderId?: string
|
||||
crrgBsnNm?: string
|
||||
amount?: number
|
||||
totalPrice?: number
|
||||
wPayOrAPay?: number
|
||||
@@ -31,6 +43,8 @@ type OrderCreateRequest = {
|
||||
orderNo?: string
|
||||
orderNumberId?: string
|
||||
amount?: number
|
||||
addressId?: string
|
||||
remark?: string
|
||||
goods?: CheckoutGoods[]
|
||||
}
|
||||
|
||||
@@ -47,6 +61,58 @@ export const orderListController = withErrorBoundary(async (request: Request, _c
|
||||
return toHttpResponse(await orderListService.listOrders(supplierId, userId))
|
||||
})
|
||||
|
||||
export const orderCountController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
const body = await readJson<OrderListRequest>(request)
|
||||
const supplierId = String(body.supplierId || '').trim()
|
||||
const userId = String(body.userId || '').trim()
|
||||
|
||||
return toHttpResponse(await orderListService.countOrders(supplierId, userId))
|
||||
})
|
||||
|
||||
export const orderDetailController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
const body = await readJson<OrderListRequest>(request)
|
||||
const supplierId = String(body.supplierId || '').trim()
|
||||
const userId = String(body.userId || '').trim()
|
||||
const orderId = String(body.orderId || '').trim()
|
||||
const mainOrderId = String(body.mainOrderId || '').trim()
|
||||
|
||||
return toHttpResponse(await orderListService.detailOrder(supplierId, userId, orderId, mainOrderId))
|
||||
})
|
||||
|
||||
export const afterSaleApplyController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await afterSaleService.apply(await readJson<AfterSaleApplyInput>(request)))
|
||||
})
|
||||
|
||||
export const afterSaleListController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await afterSaleService.list(await readJson<AfterSaleListInput>(request)))
|
||||
})
|
||||
|
||||
export const afterSaleAuditController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await afterSaleService.audit(await readJson<AfterSaleAuditInput>(request)))
|
||||
})
|
||||
|
||||
export const afterSaleLogisticsController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await afterSaleService.updateLogistics(await readJson<AfterSaleLogisticsInput>(request)))
|
||||
})
|
||||
|
||||
export const orderCreateController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
@@ -59,6 +125,8 @@ export const orderCreateController = withErrorBoundary(async (request: Request,
|
||||
orderNo: String(body.orderNo || '').trim(),
|
||||
orderNumberId: body.orderNumberId,
|
||||
amount: body.amount,
|
||||
addressId: String(body.addressId || '').trim(),
|
||||
remark: String(body.remark || '').trim(),
|
||||
goods: Array.isArray(body.goods) ? body.goods : []
|
||||
}))
|
||||
})
|
||||
@@ -121,6 +189,22 @@ export const orderPayController = withErrorBoundary(async (request: Request, _co
|
||||
}))
|
||||
})
|
||||
|
||||
export const orderShipController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
const body = await readJson<OrderActionRequest>(request)
|
||||
|
||||
return toHttpResponse(await orderActionService.shipOrder({
|
||||
supplierId: String(body.supplierId || '').trim(),
|
||||
userId: String(body.userId || '').trim(),
|
||||
orderId: String(body.orderId || body.mainOrderId || '').trim(),
|
||||
deliveryStatus: Number(body.deliveryStatus || 1),
|
||||
logisticsOrderId: String(body.logisticsOrderId || '').trim(),
|
||||
crrgBsnNm: String(body.crrgBsnNm || '').trim()
|
||||
}))
|
||||
})
|
||||
|
||||
export const orderPushEventController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
Reference in New Issue
Block a user