Answer the question
In order to leave comments, you need to log in
What is the best way to design an application?
I decided to write a small application in python in order to consolidate the acquired knowledge. While writing the code, I read about OOP and decided to make everything more abstract, in which I actually ask for help.
The cron application accesses the service, logs in, receives json with data. json contains data:
{
"data": [{
"Conception": 'Shop1',
"Delivery.IsDelivery": "ORDER_WITHOUT_DELIVERY",
"DishDiscountSumInt": 0,
"DishDiscountSumInt.average": 0,
"OpenDate.Typed": "2016-01-11T00:00:00",
"UniqOrderId.OrdersCount": 2
}, {
"Conception": "Shop2",
"Delivery.IsDelivery": "DELIVERY_ORDER",
"DishDiscountSumInt": 18895,
"DishDiscountSumInt.average": 2699.29,
"OpenDate.Typed": "2016-01-11T00:00:00",
"UniqOrderId.OrdersCount": 7
}, {
"Conception": "Shop2",
"Delivery.IsDelivery": "ORDER_WITHOUT_DELIVERY",
"DishDiscountSumInt": 63376,
"DishDiscountSumInt.average": 358.06,
"OpenDate.Typed": "2016-01-11T00:00:00",
"UniqOrderId.OrdersCount": 177
}],
"summary": [
[{
"Conception": null,
"OpenDate.Typed": "2016-01-11T00:00:00"
}, {
"DishDiscountSumInt": 0,
"DishDiscountSumInt.average": 0,
"UniqOrderId.OrdersCount": 2
}],
[{
"Conception": "Shop2",
"Delivery.IsDelivery": "DELIVERY_ORDER"
}, {
"DishDiscountSumInt": 18895,
"DishDiscountSumInt.average": 2699.29,
"UniqOrderId.OrdersCount": 7
}],
[
{}, {
"DishDiscountSumInt": 82271,
"DishDiscountSumInt.average": 442.32,
"UniqOrderId.OrdersCount": 186
}
],
[{
"Conception": "Shop2",
"Delivery.IsDelivery": "ORDER_WITHOUT_DELIVERY"
}, {
"DishDiscountSumInt": 63376,
"DishDiscountSumInt.average": 358.06,
"UniqOrderId.OrdersCount": 177
}],
[{
"Conception": null,
"Delivery.IsDelivery": "ORDER_WITHOUT_DELIVERY"
}, {
"DishDiscountSumInt": 0,
"DishDiscountSumInt.average": 0,
"UniqOrderId.OrdersCount": 2
}],
[{
"Conception": "Shop2"
}, {
"DishDiscountSumInt": 82271,
"DishDiscountSumInt.average": 447.13,
"UniqOrderId.OrdersCount": 184
}],
[{
"OpenDate.Typed": "2016-01-11T00:00:00"
}, {
"DishDiscountSumInt": 82271,
"DishDiscountSumInt.average": 442.32,
"UniqOrderId.OrdersCount": 186
}],
[{
"Conception": null
}, {
"DishDiscountSumInt": 0,
"DishDiscountSumInt.average": 0,
"UniqOrderId.OrdersCount": 2
}],
[{
"Conception": "Shop2",
"Delivery.IsDelivery": "DELIVERY_ORDER",
"OpenDate.Typed": "2016-01-11T00:00:00"
}, {
"DishDiscountSumInt": 18895,
"DishDiscountSumInt.average": 2699.29,
"UniqOrderId.OrdersCount": 7
}],
[{
"Conception": "Shop2",
"Delivery.IsDelivery": "ORDER_WITHOUT_DELIVERY",
"OpenDate.Typed": "2016-01-11T00:00:00"
}, {
"DishDiscountSumInt": 63376,
"DishDiscountSumInt.average": 358.06,
"UniqOrderId.OrdersCount": 177
}],
[{
"Conception": "Shop2",
"OpenDate.Typed": "2016-01-11T00:00:00"
}, {
"DishDiscountSumInt": 82271,
"DishDiscountSumInt.average": 447.13,
"UniqOrderId.OrdersCount": 184
}],
[{
"Conception": null,
"Delivery.IsDelivery": "ORDER_WITHOUT_DELIVERY",
"OpenDate.Typed": "2016-01-11T00:00:00"
}, {
"DishDiscountSumInt": 0,
"DishDiscountSumInt.average": 0,
"UniqOrderId.OrdersCount": 2
}]
]
}
class Conception:
# Класс хранит в себе название, показатели доставки и локальных продаж
def __init__(self, n):
self.name = n
self.delivery = ['Доставка', {'sum': 0, 'chq': 0, 'avg': 0}]
self.notdelivery = ['Прилавок', {'sum': 0, 'chq': 0, 'avg': 0}]
def setname(self, newname):
self.name = newname
def set_values_d(self, s, c, a):
self.delivery[1]['sum'] = s
self.delivery[1]['chq'] = c
self.delivery[1]['avg'] = a
def set_values_nd(self, s, c, a):
self.notdelivery[1]['sum'] = s
self.notdelivery[1]['chq'] = c
self.notdelivery[1]['avg'] = a
def __str__(self):
return 'Концепция: {0}\n''Доставка: {1}\n''Прилавок: {2}'. \
format(self.name, self.delivery, self.notdelivery)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question