42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
import { OakPreConditionUnsetException } from 'oak-domain/lib/types';
|
|
import { getOrderShipState } from '../utils/ship';
|
|
import { getShipClazz } from '../utils/shipClazz';
|
|
/**
|
|
* 获取小程序订单发货状态
|
|
* @param params
|
|
* @param context
|
|
*/
|
|
export async function getMpShipState(params, context) {
|
|
const application = context.getApplication();
|
|
const { type, } = application;
|
|
if (type === 'wechatMp') {
|
|
const { shipId } = params;
|
|
const shipState = await getOrderShipState(context, shipId);
|
|
return shipState;
|
|
}
|
|
}
|
|
/**
|
|
* 获取打印面单
|
|
*/
|
|
export async function getExpressPrintInfo(params, context) {
|
|
const { shipId } = params;
|
|
const [ship] = await context.select('ship', {
|
|
data: {
|
|
id: 1,
|
|
type: 1,
|
|
entity: 1,
|
|
entityId: 1,
|
|
extraShipId: 1,
|
|
},
|
|
filter: {
|
|
id: shipId,
|
|
}
|
|
}, { forUpdate: true });
|
|
const { type, entity, entityId, extraShipId } = ship;
|
|
if (!entity || !entityId || !extraShipId || type !== 'express') {
|
|
throw new OakPreConditionUnsetException("error::ship.noClazz", "ship", undefined, "oak-pay-business");
|
|
}
|
|
const clazz = await getShipClazz(entity, entityId, context);
|
|
return await clazz.getPrintInfo(shipId, context);
|
|
}
|