feat: 积分商城-供应商
This commit is contained in:
@@ -23,6 +23,13 @@ export const merchantOrderListController = withErrorBoundary(async (request: Req
|
||||
return toHttpResponse(await merchantService.listOrders(await readJson<MerchantOrderListInput>(request)))
|
||||
})
|
||||
|
||||
export const merchantSupplierListController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await merchantService.listSuppliers())
|
||||
})
|
||||
|
||||
export const merchantOrderShipController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
@@ -14,7 +14,11 @@ 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'
|
||||
import { orderPushEventService, type OrderPushEventInput } from '../services/order-push-event.service.js'
|
||||
import { supplierOpenOrderService, type SupplierOrderQueryRequest } from '../services/supplier-open-order.service.js'
|
||||
import {
|
||||
supplierOpenOrderService,
|
||||
type SupplierOrderQueryRequest,
|
||||
type SupplierReconciliationQueryRequest
|
||||
} from '../services/supplier-open-order.service.js'
|
||||
import { toHttpResponse } from './controller-response.js'
|
||||
|
||||
type OrderListRequest = {
|
||||
@@ -239,3 +243,21 @@ export const supplierOrderInfoController = withErrorBoundary(async (request: Req
|
||||
|
||||
return Response.json(await supplierOpenOrderService.queryOrderInfo(body))
|
||||
})
|
||||
|
||||
export const supplierReconciliationInfoController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
let body: SupplierReconciliationQueryRequest
|
||||
try {
|
||||
body = supplierOpenOrderService.parseBody(await readJson<SupplierReconciliationQueryRequest>(request))
|
||||
} catch (error) {
|
||||
return Response.json({
|
||||
resultCode: 400,
|
||||
message: error instanceof Error ? error.message : '请求参数解密失败',
|
||||
orderInfos: []
|
||||
})
|
||||
}
|
||||
|
||||
return Response.json(await supplierOpenOrderService.queryReconciliationInfo(body))
|
||||
})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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 { productService } from '../services/product.service.js'
|
||||
import { toHttpResponse } from './controller-response.js'
|
||||
@@ -25,3 +26,28 @@ export const productDetailController = withErrorBoundary(async (request: Request
|
||||
|
||||
return toHttpResponse(await productService.getProductDetail(id, sku))
|
||||
})
|
||||
|
||||
export const merchantProductListController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
const body = await readJson<{ keyword?: string; categoryId?: string }>(request)
|
||||
return toHttpResponse(await productService.listManageProducts(String(body.keyword || '').trim(), String(body.categoryId || '').trim()))
|
||||
})
|
||||
|
||||
export const merchantProductSaveController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await productService.saveManageProduct(
|
||||
await readJson<Parameters<typeof productService.saveManageProduct>[0]>(request)
|
||||
))
|
||||
})
|
||||
|
||||
export const merchantProductDeleteController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
const body = await readJson<{ id?: number }>(request)
|
||||
return toHttpResponse(await productService.deleteManageProduct(Number(body.id || 0)))
|
||||
})
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import type { Context } from '../utils/handler.js'
|
||||
import { withErrorBoundary } from '../utils/handler.js'
|
||||
import { guardMethod } from '../utils/method.js'
|
||||
import { readJson } from '../utils/request.js'
|
||||
import { toHttpResponse } from './controller-response.js'
|
||||
import { supplierOpenOrderService } from '../services/supplier-open-order.service.js'
|
||||
import {
|
||||
reconciliationResultService,
|
||||
type ReconciliationResultCallbackInput,
|
||||
type ReconciliationResultListInput,
|
||||
type ReconciliationResultUpdateInput
|
||||
} from '../services/reconciliation-result.service.js'
|
||||
|
||||
type UnReconciledMsgInput = {
|
||||
supplierId?: string
|
||||
token?: string
|
||||
timestamp?: number
|
||||
orderIds?: string
|
||||
unReconciledType?: number
|
||||
unReconciledMsg?: string
|
||||
uniqueSeqNo?: string
|
||||
AplParmObjct?: string
|
||||
}
|
||||
|
||||
export const supplierReconciliationResultController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
let body: ReconciliationResultCallbackInput
|
||||
try {
|
||||
body = supplierOpenOrderService.parseBody(await readJson<ReconciliationResultCallbackInput>(request)) as ReconciliationResultCallbackInput
|
||||
} catch (error) {
|
||||
return Response.json({ resultCode: 400, message: error instanceof Error ? error.message : '请求参数解密失败' })
|
||||
}
|
||||
return Response.json(await reconciliationResultService.receiveCallback(body))
|
||||
})
|
||||
|
||||
export const supplierUnReconciledMsgController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
let body: UnReconciledMsgInput
|
||||
try {
|
||||
body = supplierOpenOrderService.parseBody(await readJson<UnReconciledMsgInput>(request)) as UnReconciledMsgInput
|
||||
} catch (error) {
|
||||
return Response.json({ resultCode: 400, message: error instanceof Error ? error.message : '请求参数解密失败' })
|
||||
}
|
||||
const reconciliationResults = String(body.orderIds || '').split(',').map(orderId => orderId.trim()).filter(Boolean).map(orderId => ({
|
||||
orderId,
|
||||
reconciliationStatus: 2,
|
||||
diffType: body.unReconciledType === undefined ? undefined : Number(body.unReconciledType),
|
||||
diffReason: body.unReconciledMsg
|
||||
}))
|
||||
return Response.json(await reconciliationResultService.receiveCallback({
|
||||
supplierId: body.supplierId,
|
||||
token: body.token,
|
||||
timestamp: body.timestamp,
|
||||
reconciliationBatchNo: body.uniqueSeqNo,
|
||||
reconciliationResults
|
||||
}))
|
||||
})
|
||||
|
||||
export const merchantReconciliationListController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await reconciliationResultService.list(await readJson<ReconciliationResultListInput>(request)))
|
||||
})
|
||||
|
||||
export const merchantReconciliationUpdateController = withErrorBoundary(async (request: Request, _context: Context) => {
|
||||
const methodResponse = guardMethod(request, ['POST'])
|
||||
if (methodResponse) return methodResponse
|
||||
|
||||
return toHttpResponse(await reconciliationResultService.update(await readJson<ReconciliationResultUpdateInput>(request)))
|
||||
})
|
||||
Reference in New Issue
Block a user