Added orderrow fields
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import { SQLDataSource } from 'datasource-sql';
|
||||
|
||||
import { BaseSQLDataSource } from './BaseSQLDataSource';
|
||||
import { camelcase } from 'stringcase';
|
||||
import {
|
||||
@@ -10,6 +8,8 @@ import {
|
||||
OrderRow,
|
||||
} from './order-types';
|
||||
import { GeneralInput, Maybe } from './types';
|
||||
import { convertToPossibleType } from './utils';
|
||||
import { getProductGroupStringFromString } from './product-types';
|
||||
|
||||
const MINUTE = 60;
|
||||
export class OrderAPI extends BaseSQLDataSource {
|
||||
@@ -142,12 +142,15 @@ export class OrderAPI extends BaseSQLDataSource {
|
||||
const fields = await this.getOrderRowFieldMapping();
|
||||
|
||||
const orderRow = details.reduce((obj, item) => {
|
||||
obj[camelcase(fields[item.fieldid])] = item.value;
|
||||
const value = convertToPossibleType(item.value);
|
||||
|
||||
obj[camelcase(fields[item.fieldid])] = value;
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
if ('group' in orderRow) {
|
||||
orderRow['productGroup'] = orderRow['group'];
|
||||
orderRow['group'] = getProductGroupStringFromString(orderRow['group']);
|
||||
}
|
||||
return orderRow;
|
||||
}
|
||||
@@ -172,6 +175,7 @@ export class OrderAPI extends BaseSQLDataSource {
|
||||
|
||||
orderRows.push(orderRow);
|
||||
}
|
||||
|
||||
return orderRows;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,18 +81,49 @@ export interface Order {
|
||||
|
||||
export interface OrderRow {
|
||||
id: number;
|
||||
inserted: Date;
|
||||
orderId: number;
|
||||
productId: number;
|
||||
productGroup: string;
|
||||
artNo: string;
|
||||
path: string;
|
||||
name: string;
|
||||
price: number;
|
||||
designerId: string;
|
||||
commissionAmount: string;
|
||||
status: string;
|
||||
pwintyImageId: number;
|
||||
code: string;
|
||||
commission: number;
|
||||
commissionAmount: number;
|
||||
commissionResale: number;
|
||||
designer: string;
|
||||
designerId: number;
|
||||
designerPath: string;
|
||||
discountType: string;
|
||||
discountValue: number;
|
||||
displayHeight: number;
|
||||
displayWidth: number;
|
||||
edge: number;
|
||||
frameColor: string;
|
||||
framed: number;
|
||||
group: string;
|
||||
height: number;
|
||||
imagedonotprint: number;
|
||||
imageprocessed: number;
|
||||
imageprocessingrejected: number;
|
||||
inserted: Date;
|
||||
material: string;
|
||||
measureUnit: string;
|
||||
mirrored: number;
|
||||
modifier: string;
|
||||
name: string;
|
||||
noShipping: boolean;
|
||||
order: Order;
|
||||
orderId: number;
|
||||
path: string;
|
||||
price: number;
|
||||
printId: number;
|
||||
process: Boolean;
|
||||
productGroup: string;
|
||||
productId: number;
|
||||
pwintyImageId: number;
|
||||
pwintySku: string;
|
||||
resolution: number;
|
||||
status: string;
|
||||
type: string;
|
||||
vat: number;
|
||||
weight: number;
|
||||
width: number;
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,17 @@ export class ProductAPI extends SQLDataSource {
|
||||
return res;
|
||||
}
|
||||
|
||||
async getMaterial(printId: number): Promise<any> {
|
||||
// SELECT materialid, material, (price / 100::float) as price FROM "product-materials"
|
||||
}
|
||||
|
||||
// TODO: get product details
|
||||
async getProductDetails(id: number): Promise<any> {
|
||||
// SELECT * FROM "product-fields";
|
||||
// SELECT * FROM "product-products_fields" WHERE productid = 58941;
|
||||
return null;
|
||||
}
|
||||
|
||||
getBlacklisting(row: any): Array<ProductBlacklist> {
|
||||
if (!row.blacklisting) {
|
||||
return [];
|
||||
|
||||
@@ -2,10 +2,37 @@ export enum ProductGroup {
|
||||
PHOTO_WALLPAPER = 1,
|
||||
CANVAS = 2,
|
||||
WALLPAPER = 3,
|
||||
OLD_REMOVED = 4,
|
||||
DO_IT_YOURSELF_FRAME = 5,
|
||||
DESIGNER_WALLPAPER = 6,
|
||||
POSTER = 7,
|
||||
FRAMED_PRINT = 8,
|
||||
UNKNOWN = 9,
|
||||
}
|
||||
|
||||
export function getProductGroupStringFromString(group: string): string {
|
||||
return ProductGroup[getProductGroupFromString(group)];
|
||||
}
|
||||
|
||||
export function getProductGroupFromString(group: string): ProductGroup {
|
||||
switch (group) {
|
||||
case 'canvas':
|
||||
return ProductGroup.CANVAS;
|
||||
case 'framed-print':
|
||||
return ProductGroup.FRAMED_PRINT;
|
||||
case 'photo-wallpaper':
|
||||
return ProductGroup.PHOTO_WALLPAPER;
|
||||
case 'poster':
|
||||
return ProductGroup.POSTER;
|
||||
case 'wallpaper':
|
||||
return ProductGroup.WALLPAPER;
|
||||
case 'design-wallpaper':
|
||||
return ProductGroup.DESIGNER_WALLPAPER;
|
||||
case 'doityourselfframe':
|
||||
return ProductGroup.DO_IT_YOURSELF_FRAME;
|
||||
default:
|
||||
return ProductGroup.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
|
||||
Reference in New Issue
Block a user