|
@@ -909,16 +909,62 @@ class serveManagement(View):
|
|
|
page = int(page_no)
|
|
|
line = int(page_size)
|
|
|
try:
|
|
|
- order_qs = DailyReconciliation.objects.all()
|
|
|
+ daily_reconciliation = DailyReconciliation.objects.all()
|
|
|
# 筛选指定订单
|
|
|
if start_time and end_time:
|
|
|
- order_qs = order_qs.filter(time__gte=start_time, time__lt=end_time)
|
|
|
- if not order_qs.exists():
|
|
|
+ daily_reconciliation = daily_reconciliation.filter(time__gte=start_time, time__lt=end_time)
|
|
|
+ if not daily_reconciliation.exists():
|
|
|
return response.json(0, [])
|
|
|
- count = order_qs.count()
|
|
|
- order_qs = order_qs.values("id", "trade_nos", "ansjer_total", "ansjer_num", "paypal_num", "paypal_total",
|
|
|
- "time").order_by('-time')[(page - 1) * line:page * line]
|
|
|
- return response.json(0, {'list': list(order_qs), 'total': count})
|
|
|
+ count = daily_reconciliation.count()
|
|
|
+ daily_reconciliation_qs = daily_reconciliation.values("id", "order_ids", "ansjer_total", "ansjer_num",
|
|
|
+ "paypal_num", "paypal_total", "time").order_by(
|
|
|
+ '-time')[(page - 1) * line:page * line]
|
|
|
+ for item in daily_reconciliation_qs:
|
|
|
+ item['order_info'] = []
|
|
|
+ if not item['order_ids']:
|
|
|
+ continue
|
|
|
+ order_list = item['order_ids'].split(',')
|
|
|
+ order_qs = Order_Model.objects.filter(Q(orderID__in=order_list) | Q(trade_no__in=order_list)).values(
|
|
|
+ "orderID", "UID", "userID__username", "userID__NickName", "channel", "desc", "price",
|
|
|
+ "refunded_amount", "currency", "addTime", "updTime", "paypal", "payType", "rank__day",
|
|
|
+ "rank__price", "status", "order_type", "paymentID", "trade_no", "payTime", "userID__region_country",
|
|
|
+ "userID__phone").order_by('-addTime')
|
|
|
+ while True:
|
|
|
+ params = {'pageNo': 1, 'pageSize': 100, 'order_list': item['order_ids']}
|
|
|
+ eur_response = requests.get('https://www.zositeche.com/serveManagement/getDeviceOrderList', params)
|
|
|
+ if eur_response.status_code == 200:
|
|
|
+ result = eur_response.json()
|
|
|
+ if result['result_code'] == 0:
|
|
|
+ item['order_info'] = result['result']['list']
|
|
|
+ break
|
|
|
+ for order in order_qs:
|
|
|
+ # 查询国家信息
|
|
|
+ country = 'N/A'
|
|
|
+ country_qs = CountryModel.objects.filter(id=order['userID__region_country']).values('country_name')
|
|
|
+ if country_qs.exists():
|
|
|
+ country = country_qs[0]['country_name']
|
|
|
+ serial_number = CommonService.query_serial_with_uid(order['UID'])
|
|
|
+ data = {'orderID': order['orderID'], 'UID': order['UID'],
|
|
|
+ 'userID__username': order['userID__username'],
|
|
|
+ 'userID__NickName': order['userID__NickName'], 'channel': order['channel'],
|
|
|
+ 'desc': order['desc'], 'price': order['price'], 'refunded_amount': order['refunded_amount'],
|
|
|
+ 'currency': order['currency'], 'addTime': order['addTime'], 'updTime': order['updTime'],
|
|
|
+ 'paypal': order['paypal'], 'payType': order['payType'], 'rank__day': order['rank__day'],
|
|
|
+ 'rank__price': order['rank__price'], 'status': order['status'],
|
|
|
+ 'order_type': order['order_type'],
|
|
|
+ 'payTime': order['payTime'] if order['payTime'] else 'N/A',
|
|
|
+ 'serialNumber': 'N/A' if serial_number == order['UID'] else serial_number,
|
|
|
+ 'country': country, 'userID__phone': order['userID__phone'], 'trade_no': 'N/A'}
|
|
|
+ # 添加PayPal交易号字段
|
|
|
+ if data['payType'] == 1:
|
|
|
+ data['trade_no'] = order['trade_no'] if order['trade_no'] else 'N/A'
|
|
|
+ data['express_id'] = ''
|
|
|
+ if data['payType'] == 11:
|
|
|
+ cdk_context_qs = CDKcontextModel.objects.filter(order=data['orderID']).values('express_id')
|
|
|
+ if cdk_context_qs.exists():
|
|
|
+ data['express_id'] = cdk_context_qs[0]['express_id']
|
|
|
+ item['order_info'].append(data)
|
|
|
+ return response.json(0, {'list': list(daily_reconciliation_qs), 'total': count})
|
|
|
except Exception as e:
|
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
@@ -1708,7 +1754,8 @@ class serveManagement(View):
|
|
|
return response.json(0)
|
|
|
uid_bucket_qs = UID_Bucket.objects.filter(uid=uid, use_status=1, orderId='').values('endTime')
|
|
|
if uid_bucket_qs.exists(): # 如果通过uid查询正在使用的套餐,则更新过期时间和使用状态
|
|
|
- end_time = pay_time + uid_bucket_qs[0]['endTime'] - CommonService.calcMonthLater(expire, pay_time)
|
|
|
+ end_time = pay_time + uid_bucket_qs[0]['endTime'] - CommonService.calcMonthLater(expire,
|
|
|
+ pay_time)
|
|
|
use_status = 2 if end_time < nowTime else 1
|
|
|
uid_bucket_qs.update(endTime=end_time, use_status=use_status, updateTime=nowTime)
|
|
|
return response.json(0)
|