statistics_func.py
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- coding:utf-8 -*-
#@Time : 2021/2/5 10:32
#@File : statistics_func.py
#@Auth : bianxinhua
from datetime import date, timedelta
import datetime
###获取季度
def quarters1() :
today = datetime.date.today()
quarter = (today.month-1) // 3
return quarter
def get_quarters(key,*args_v):
quarters = args_v[0][quarters1() - 1][key]
return quarters
def get_statistics(*args_v):
value = []
statistics = []
for i in range(len(args_v)-1):
value.append(args_v[i])
for v in value:
statistics.append(args_v[-1][v])
return sum(statistics)
#统计应收/已收/未收
def statistics_func(keys,*args_v):
# print("====================args_v===============================")
# print(args_v)
# print(keys)
value = []
num = 0
for i in range(len(args_v)):
if args_v[i] == []:
value.append(0)
else:
for j in range(len(args_v[i])):
value.append((args_v[i][j][keys]))
for v in value:
if type(v) == str:
v = float(v)
num = num + v
# print("===========================================================")
# print('num=',num)
return num
#统计订单金额
def statistics_actual_func(keys,*args_v):
# print("====================args_v===============================")
# print(args_v)
value = []
for i in range(len(args_v)):
for j in range(len(args_v[i])):
if args_v[i][j]['partnerCategory'] == keys:
value.append(args_v[i][j]['orderPrice'])
# print("===========================================================")
# print('value=',value)
return sum(value)
#统计个数
def statistics_num_func(keys,*args_v):
value = []
num = 0
for i in range(len(args_v)):
for j in range(len(args_v[i])):
value.append(args_v[i][j][keys])
for v in range(len(value)):
if float(value[v]) > 0 :
num = num +1
# print(num)
return num