|
@@ -21,7 +21,7 @@ from django.views.generic.base import View
|
|
|
from Ansjer.config import LOGGER
|
|
|
from Model.models import UnicomDeviceInfo, UnicomCombo, Pay_Type, Order_Model, Store_Meal, AiStoreMeal, \
|
|
|
UnicomComboOrderInfo, UnicomComboExperienceHistory, UnicomDeviceStatusChangePush, SysMsgModel, LogModel, \
|
|
|
- DeviceLiveRestrict
|
|
|
+ DeviceLiveRestrict, OrderPayLog
|
|
|
from Object.EIoTClubObject import EIoTClubObject
|
|
|
from Object.Enums.WXOperatorEnum import WXOperatorEnum
|
|
|
from Object.RedisObject import RedisObject
|
|
@@ -202,7 +202,7 @@ class UnicomComboView(View):
|
|
|
return False
|
|
|
c_time = combo_order_qs[0].created_time
|
|
|
# 根据序列号获取UID
|
|
|
- uid = CommonService.query_uid_with_serial(serial_no)
|
|
|
+ uid = CommonService.get_uid_by_serial_number(serial_no)
|
|
|
order_id = CommonService.createOrderID()
|
|
|
rank_id, ai_rank_id = cls.get_cloud_or_ai_combo() # 生成订单必须添加该字段
|
|
|
order_dict = {'orderID': order_id, 'UID': uid, 'rank_id': rank_id, 'ai_rank_id': ai_rank_id,
|
|
@@ -613,7 +613,7 @@ class UnicomComboView(View):
|
|
|
if not price:
|
|
|
return response.json(173)
|
|
|
unicom_device_qs = unicom_device_qs.first()
|
|
|
- device_uid = CommonService.query_uid_with_serial(unicom_device_qs['serial_no'])
|
|
|
+ device_uid = CommonService.get_uid_by_serial_number(unicom_device_qs['serial_no'])
|
|
|
order_id = CommonService.createOrderID()
|
|
|
rank_id, ai_rank_id = cls.get_cloud_or_ai_combo()
|
|
|
|
|
@@ -627,6 +627,8 @@ class UnicomComboView(View):
|
|
|
|
|
|
params = 'lang=cn' + '&activateType=' + activate_type
|
|
|
logger.info('激活类型:{}'.format(activate_type))
|
|
|
+ serial_number = unicom_device_qs['serial_no']
|
|
|
+
|
|
|
result = {'result_code': 0, 'reason': 'success', 'error_code': 0}
|
|
|
if pay_type == 2: # 支付宝
|
|
|
pay_price = PayService.get_two_float(price, 2)
|
|
@@ -637,6 +639,7 @@ class UnicomComboView(View):
|
|
|
notify_url,
|
|
|
unicom_combo_qs['remark'], response)
|
|
|
res_data = {'redirectUrl': order_dict['pay_url'], 'orderID': order_id}
|
|
|
+ cls.create_order_pay_log(order_id, f'{serial_number}购买联通4G套餐', notify_url, 'aliPay', 'SUCCESS')
|
|
|
elif pay_type == 3: # 微信支付
|
|
|
notify_url = 'unicom/wap/pay/wechat-notify'
|
|
|
ip = CommonService.get_ip_address(request)
|
|
@@ -647,6 +650,7 @@ class UnicomComboView(View):
|
|
|
unicom_combo_qs['remark'],
|
|
|
response)
|
|
|
result['result'] = sign_params
|
|
|
+ cls.create_order_pay_log(order_id, f'{serial_number}购买联通4G套餐', notify_url, 'wechatPay', 'SUCCESS')
|
|
|
else:
|
|
|
return response.json(444, {'param': 'pay_type'})
|
|
|
|
|
@@ -1140,3 +1144,66 @@ class UnicomComboView(View):
|
|
|
'{}update_flow_package_order_by_iccid,errLine:{}, errMsg:{}'.format(iccid, e.__traceback__.tb_lineno,
|
|
|
repr(e)))
|
|
|
return False
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def create_order_pay_log(order_id, business_name, api_url, sender, access_result):
|
|
|
+ """
|
|
|
+ 订单支付日志
|
|
|
+ @param order_id: 订单ID
|
|
|
+ @param business_name: 业务名称
|
|
|
+ @param api_url: 回调api地址
|
|
|
+ @param sender: 发送方/调用方
|
|
|
+ @param access_result: 获取支付请求结果
|
|
|
+ @return: True | False
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ LOGGER.info(f'***创建订单支付日志order_id={order_id}')
|
|
|
+ now_time = int(time.time())
|
|
|
+ params = {
|
|
|
+ 'order_id': order_id,
|
|
|
+ 'business_name': business_name,
|
|
|
+ 'api_url': api_url, 'sender': sender, 'access_result': access_result, 'created_time': now_time,
|
|
|
+ 'updated_time': now_time,
|
|
|
+ }
|
|
|
+ OrderPayLog.objects.create(**params)
|
|
|
+ return True
|
|
|
+ except Exception as e:
|
|
|
+ LOGGER.info('{}create_order_pay_log,errLine:{}, errMsg:{}'.
|
|
|
+ format(order_id, e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ return False
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def save_order_pay_log(order_id, trade_no, api_url, sender, access_result, response_content):
|
|
|
+ """
|
|
|
+ 保存订单支付日志
|
|
|
+ @param order_id: 订单ID
|
|
|
+ @param trade_no: 交易流水号
|
|
|
+ @param api_url: 异步回调API
|
|
|
+ @param sender: 发送方/调用方
|
|
|
+ @param access_result: 调用结果
|
|
|
+ @param response_content: 响应内容
|
|
|
+ @return: True | False
|
|
|
+ """
|
|
|
+ try:
|
|
|
+ LOGGER.info(f'***保存支付回调记录order_id={order_id},流水号={trade_no}')
|
|
|
+ now_time = int(time.time())
|
|
|
+ params = {
|
|
|
+ 'access_result': access_result,
|
|
|
+ 'updated_time': now_time,
|
|
|
+ 'trans_serial_no': trade_no,
|
|
|
+ 'response_content': response_content
|
|
|
+ }
|
|
|
+ pay_log_qs = OrderPayLog.objects.filter(order_id=order_id)
|
|
|
+ if pay_log_qs.exists():
|
|
|
+ pay_log_qs.update(**params)
|
|
|
+ return True
|
|
|
+ params['order_id'] = order_id
|
|
|
+ params['api_url'] = api_url
|
|
|
+ params['sender'] = sender
|
|
|
+ params['created_time'] = now_time
|
|
|
+ OrderPayLog.objects.create(**params)
|
|
|
+ return True
|
|
|
+ except Exception as e:
|
|
|
+ LOGGER.info('{}save_order_pay_log,errLine:{}, errMsg:{}'.
|
|
|
+ format(order_id, e.__traceback__.tb_lineno, repr(e)))
|
|
|
+ return False
|