|
@@ -72,8 +72,8 @@ class OperatingCostsDataView(View):
|
|
|
operating_qs = operating_costs_qs.values('order_id', 'uid', 'day_average_price', 'month_average_price',
|
|
|
'purchase_quantity', 'actual_storage', 'actual_api',
|
|
|
'monthly_income', 'settlement_days', 'remaining_usage_time',
|
|
|
- 'end_time', 'created_time', 'time').order_by('-time')[
|
|
|
- (page - 1) * line:page * line]
|
|
|
+ 'end_time', 'created_time', 'start_time', 'time').order_by(
|
|
|
+ '-time')[(page - 1) * line:page * line]
|
|
|
all_order_qs = Order_Model.objects.filter(orderID__in=order_list)
|
|
|
country_qs = CountryModel.objects.values('id', 'country_name')
|
|
|
country_dict = {}
|
|
@@ -92,16 +92,14 @@ class OperatingCostsDataView(View):
|
|
|
region = '国内' if CONFIG_INFO == CONFIG_CN else '国外'
|
|
|
if order_qs[0]['order_type'] in [0, 1]:
|
|
|
order_type = '云存'
|
|
|
- order_start_time = int((datetime.datetime.fromtimestamp(item['end_time']) - relativedelta(
|
|
|
- months=order_qs[0]['rank__expire'])).timestamp())
|
|
|
- storage_cost = float(item['actual_storage']) / 1024 * storage_univalence * item['settlement_days']
|
|
|
- api_cost = int(item['actual_api']) * api_univalence
|
|
|
+ storage_cost = round(
|
|
|
+ float(item['actual_storage']) / 1024 * storage_univalence * item['settlement_days'], 2)
|
|
|
+ api_cost = round(int(item['actual_api']) * api_univalence, 2)
|
|
|
if CONFIG_INFO == CONFIG_CN: # 国内要换算汇率
|
|
|
storage_cost = storage_cost * 7
|
|
|
api_cost = api_cost * 7
|
|
|
- profit = round(float(item['monthly_income']) - storage_cost - api_cost, 2)
|
|
|
- else:
|
|
|
- profit = round(float(item['monthly_income']) - storage_cost - api_cost, 2)
|
|
|
+ profit = round(float(item['monthly_income']) - storage_cost - api_cost, 2) # 利润=月结算金额-月成本
|
|
|
+ profit_margin = round(profit / float(item['month_average_price']), 2) # 利润率=利润/每月收入分摊
|
|
|
expire = str(order_qs[0]['rank__expire']) + '个月'
|
|
|
else:
|
|
|
order_type = '4G流量'
|
|
@@ -124,7 +122,7 @@ class OperatingCostsDataView(View):
|
|
|
'day_average_price': item['day_average_price'],
|
|
|
'month_average_price': item['month_average_price'],
|
|
|
'purchase_quantity': item['purchase_quantity'],
|
|
|
- 'start_time': order_start_time,
|
|
|
+ 'start_time': item['start_time'],
|
|
|
'end_time': item['end_time'],
|
|
|
'settlement_time': item['created_time'],
|
|
|
'settlement_days': item['settlement_days'],
|
|
@@ -135,6 +133,7 @@ class OperatingCostsDataView(View):
|
|
|
'storage_cost': storage_cost,
|
|
|
'api_cost': api_cost,
|
|
|
'profit': profit,
|
|
|
+ 'profit_margin': profit_margin,
|
|
|
'time': item['time']
|
|
|
})
|
|
|
# if CONFIG_INFO == CONFIG_US:
|