Added orderrow fields
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
import { SQLDataSource } from 'datasource-sql';
|
|
||||||
|
|
||||||
import { BaseSQLDataSource } from './BaseSQLDataSource';
|
import { BaseSQLDataSource } from './BaseSQLDataSource';
|
||||||
import { camelcase } from 'stringcase';
|
import { camelcase } from 'stringcase';
|
||||||
import {
|
import {
|
||||||
@@ -10,6 +8,8 @@ import {
|
|||||||
OrderRow,
|
OrderRow,
|
||||||
} from './order-types';
|
} from './order-types';
|
||||||
import { GeneralInput, Maybe } from './types';
|
import { GeneralInput, Maybe } from './types';
|
||||||
|
import { convertToPossibleType } from './utils';
|
||||||
|
import { getProductGroupStringFromString } from './product-types';
|
||||||
|
|
||||||
const MINUTE = 60;
|
const MINUTE = 60;
|
||||||
export class OrderAPI extends BaseSQLDataSource {
|
export class OrderAPI extends BaseSQLDataSource {
|
||||||
@@ -142,12 +142,15 @@ export class OrderAPI extends BaseSQLDataSource {
|
|||||||
const fields = await this.getOrderRowFieldMapping();
|
const fields = await this.getOrderRowFieldMapping();
|
||||||
|
|
||||||
const orderRow = details.reduce((obj, item) => {
|
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;
|
return obj;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
if ('group' in orderRow) {
|
if ('group' in orderRow) {
|
||||||
orderRow['productGroup'] = orderRow['group'];
|
orderRow['productGroup'] = orderRow['group'];
|
||||||
|
orderRow['group'] = getProductGroupStringFromString(orderRow['group']);
|
||||||
}
|
}
|
||||||
return orderRow;
|
return orderRow;
|
||||||
}
|
}
|
||||||
@@ -172,6 +175,7 @@ export class OrderAPI extends BaseSQLDataSource {
|
|||||||
|
|
||||||
orderRows.push(orderRow);
|
orderRows.push(orderRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
return orderRows;
|
return orderRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,18 +81,49 @@ export interface Order {
|
|||||||
|
|
||||||
export interface OrderRow {
|
export interface OrderRow {
|
||||||
id: number;
|
id: number;
|
||||||
inserted: Date;
|
|
||||||
orderId: number;
|
|
||||||
productId: number;
|
|
||||||
productGroup: string;
|
|
||||||
artNo: string;
|
artNo: string;
|
||||||
path: string;
|
code: string;
|
||||||
name: string;
|
commission: number;
|
||||||
price: number;
|
commissionAmount: number;
|
||||||
designerId: string;
|
commissionResale: number;
|
||||||
commissionAmount: string;
|
designer: string;
|
||||||
status: string;
|
designerId: number;
|
||||||
pwintyImageId: number;
|
designerPath: string;
|
||||||
|
discountType: string;
|
||||||
|
discountValue: number;
|
||||||
|
displayHeight: number;
|
||||||
|
displayWidth: number;
|
||||||
|
edge: number;
|
||||||
frameColor: string;
|
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;
|
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;
|
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> {
|
getBlacklisting(row: any): Array<ProductBlacklist> {
|
||||||
if (!row.blacklisting) {
|
if (!row.blacklisting) {
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
@@ -2,10 +2,37 @@ export enum ProductGroup {
|
|||||||
PHOTO_WALLPAPER = 1,
|
PHOTO_WALLPAPER = 1,
|
||||||
CANVAS = 2,
|
CANVAS = 2,
|
||||||
WALLPAPER = 3,
|
WALLPAPER = 3,
|
||||||
|
OLD_REMOVED = 4,
|
||||||
DO_IT_YOURSELF_FRAME = 5,
|
DO_IT_YOURSELF_FRAME = 5,
|
||||||
DESIGNER_WALLPAPER = 6,
|
DESIGNER_WALLPAPER = 6,
|
||||||
POSTER = 7,
|
POSTER = 7,
|
||||||
FRAMED_PRINT = 8,
|
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 {
|
export interface Category {
|
||||||
|
|||||||
+113
-12
@@ -106,21 +106,51 @@ const typeDefs = gql`
|
|||||||
|
|
||||||
type OrderRow {
|
type OrderRow {
|
||||||
id: ID!
|
id: ID!
|
||||||
order: Order
|
|
||||||
inserted: DateTime
|
|
||||||
orderId: Int
|
|
||||||
productId: Int
|
|
||||||
productGroup: String
|
|
||||||
artNo: String
|
artNo: String
|
||||||
path: String
|
code: String
|
||||||
name: String
|
commission: Int
|
||||||
price: Float
|
commissionAmount: Float
|
||||||
designerId: String
|
commissionResale: Int
|
||||||
commissionAmount: String
|
designer: String
|
||||||
status: String
|
designerId: Int
|
||||||
pwintyImageId: Int
|
designerPath: String
|
||||||
|
discountType: String
|
||||||
|
discountValue: Float
|
||||||
|
displayHeight: Int
|
||||||
|
displayWidth: Int
|
||||||
|
edge: Int
|
||||||
frameColor: String
|
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
|
pwintySku: String
|
||||||
|
resolution: Int
|
||||||
|
status: String
|
||||||
|
type: String
|
||||||
|
vat: Float
|
||||||
|
weight: Int
|
||||||
|
width: Int
|
||||||
|
x: Float
|
||||||
|
y: Float
|
||||||
}
|
}
|
||||||
|
|
||||||
type Category {
|
type Category {
|
||||||
@@ -146,10 +176,12 @@ const typeDefs = gql`
|
|||||||
PHOTO_WALLPAPER
|
PHOTO_WALLPAPER
|
||||||
CANVAS
|
CANVAS
|
||||||
WALLPAPER
|
WALLPAPER
|
||||||
|
OLD_REMOVED
|
||||||
DO_IT_YOURSELF_FRAME
|
DO_IT_YOURSELF_FRAME
|
||||||
DESIGNER_WALLPAPER
|
DESIGNER_WALLPAPER
|
||||||
POSTER
|
POSTER
|
||||||
FRAMED_PRINT
|
FRAMED_PRINT
|
||||||
|
UNKNOWN
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProductBlacklist {
|
type ProductBlacklist {
|
||||||
@@ -179,3 +211,72 @@ const typeDefs = gql`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export { typeDefs };
|
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