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 {
|
||||
|
||||
+113
-12
@@ -106,21 +106,51 @@ const typeDefs = gql`
|
||||
|
||||
type OrderRow {
|
||||
id: ID!
|
||||
order: Order
|
||||
inserted: DateTime
|
||||
orderId: Int
|
||||
productId: Int
|
||||
productGroup: String
|
||||
artNo: String
|
||||
path: String
|
||||
name: String
|
||||
price: Float
|
||||
designerId: String
|
||||
commissionAmount: String
|
||||
status: String
|
||||
pwintyImageId: Int
|
||||
code: String
|
||||
commission: Int
|
||||
commissionAmount: Float
|
||||
commissionResale: Int
|
||||
designer: String
|
||||
designerId: Int
|
||||
designerPath: String
|
||||
discountType: String
|
||||
discountValue: Float
|
||||
displayHeight: Int
|
||||
displayWidth: Int
|
||||
edge: Int
|
||||
frameColor: String
|
||||
framed: Int
|
||||
group: ProductGroup
|
||||
height: Int
|
||||
imagedonotprint: Int
|
||||
imageprocessed: Int
|
||||
imageprocessingrejected: Int
|
||||
inserted: DateTime
|
||||
material: String
|
||||
measureUnit: String
|
||||
mirrored: Int
|
||||
modifier: String
|
||||
name: String
|
||||
noShipping: Boolean
|
||||
order: Order
|
||||
orderId: Int
|
||||
path: String
|
||||
price: Float
|
||||
printId: Int
|
||||
process: Boolean
|
||||
productGroup: String
|
||||
productId: Int
|
||||
pwintyImageId: Int
|
||||
pwintySku: String
|
||||
resolution: Int
|
||||
status: String
|
||||
type: String
|
||||
vat: Float
|
||||
weight: Int
|
||||
width: Int
|
||||
x: Float
|
||||
y: Float
|
||||
}
|
||||
|
||||
type Category {
|
||||
@@ -146,10 +176,12 @@ const typeDefs = gql`
|
||||
PHOTO_WALLPAPER
|
||||
CANVAS
|
||||
WALLPAPER
|
||||
OLD_REMOVED
|
||||
DO_IT_YOURSELF_FRAME
|
||||
DESIGNER_WALLPAPER
|
||||
POSTER
|
||||
FRAMED_PRINT
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
type ProductBlacklist {
|
||||
@@ -179,3 +211,72 @@ const typeDefs = gql`
|
||||
`;
|
||||
|
||||
export { typeDefs };
|
||||
|
||||
/*
|
||||
orderrows example
|
||||
{
|
||||
printId: '73963',
|
||||
productId: '54192',
|
||||
group: 'photo-wallpaper',
|
||||
type: 'scaling',
|
||||
artNo: 'e50075',
|
||||
path: 'flora-hysterica-4',
|
||||
name: 'Flora Hysterica 4',
|
||||
price: '587.092480',
|
||||
width: '640',
|
||||
height: '260',
|
||||
x: '0.000000',
|
||||
y: '0.135133',
|
||||
weight: '1',
|
||||
designer: 'martin-bergstrom',
|
||||
designerId: '201',
|
||||
commission: '0',
|
||||
commissionResale: '0',
|
||||
status: 'print',
|
||||
process: 'true',
|
||||
vat: '1.210000',
|
||||
commissionAmount: '0.000000',
|
||||
framed: '0',
|
||||
mirrored: '0',
|
||||
edge: '0',
|
||||
imageprocessed: 'true',
|
||||
imageprocessingrejected: 'false',
|
||||
resolution: '150',
|
||||
imagedonotprint: 'false',
|
||||
material: 'premium-wallpaper',
|
||||
discountType: '%',
|
||||
discountValue: '25',
|
||||
measureUnit: 'cm',
|
||||
displayWidth: '640',
|
||||
displayHeight: '260',
|
||||
designerPath: 'martin-bergstrom',
|
||||
productGroup: 'photo-wallpaper',
|
||||
id: 1559849,
|
||||
orderId: 588274,
|
||||
inserted: 2021-02-04T09:58:11.243Z
|
||||
},
|
||||
{
|
||||
type: '%',
|
||||
name: 'Influencer 2021 IT',
|
||||
price: '-150.826446',
|
||||
vat: '1.210000',
|
||||
modifier: 'discount',
|
||||
code: 'mynameiseleonora25',
|
||||
noShipping: 'False',
|
||||
id: 1559850,
|
||||
orderId: 588274,
|
||||
inserted: 2021-02-04T09:58:11.243Z
|
||||
}
|
||||
|
||||
|
||||
|
||||
"doityourselfframe"
|
||||
"fixed"
|
||||
"tiling"
|
||||
"gift-voucher"
|
||||
"custom"
|
||||
"scaling"
|
||||
"%"
|
||||
"stock"
|
||||
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user