Browse Source

Merge branch 'dev' of http://192.168.136.99:3000/SERVER/AnsjerServer into dev

tanghongbin 4 năm trước cách đây
mục cha
commit
05575f1f7e
2 tập tin đã thay đổi với 76 bổ sung52 xóa
  1. 74 50
      Controller/CloudStorage.py
  2. 2 2
      Controller/EquipmentManagerV3.py

+ 74 - 50
Controller/CloudStorage.py

@@ -956,57 +956,81 @@ class CloudStorageView(View):
 
     def do_pay_by_wechat_callback(self, request_dict, response):
         result_code = request_dict.get('result_code', None)
+        asy = threading.Thread(target=ModelService.add_log,
+                               args=('回调',
+                                     '回调', request_dict))
+        asy.start()
+        try:
+            if result_code == 'SUCCESS':
+                check_sign = WechatPayObject.get_notifypay(request_dict)
+                if not check_sign:
+                    return HttpResponse(WechatPayObject.xml_to_dict({'return_code': 'FAIL', 'return_msg': '签名失败'}))
+                orderID = request_dict.get('out_trade_no', None)
+                asy = threading.Thread(target=ModelService.add_log,
+                                       args=(orderID,
+                                             '回调', '修改订单状态'))
+                asy.start()
+                self.callback_dostatus(orderID)
+                print("进来了,微信支付成功回调")
+
+                asy = threading.Thread(target=ModelService.add_log,
+                                       args=(orderID,
+                                             '回调', '进来了,微信支付成功回调'))
+                asy.start()
+                order_qs = Order_Model.objects.filter(orderID=orderID)
+                nowTime = int(time.time())
+                order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts",
+                                             "userID__userID", "userID__username")
+                userid = order_list[0]['userID__userID']
+                username = order_list[0]['userID__username']
+                UID = order_list[0]['UID']
+                channel = order_list[0]['channel']
+                rank = order_list[0]['rank']
+                smqs = Store_Meal.objects.filter(id=rank). \
+                    values("day", "bucket_id", "bucket__storeDay", "expire")
+                bucketId = smqs[0]['bucket_id']
+                if not smqs.exists():
+                    return HttpResponse(WechatPayObject.xml_to_dict({'return_code': 'FAIL', 'return_msg': '套餐不存在'}))
+                # ##
+                ubqs = UID_Bucket.objects.filter(bucket__id=bucketId, uid=UID, channel=channel, endTime__gte=nowTime). \
+                           values("id", "bucket__storeDay", "bucket__region", "endTime").order_by('addTime')[:1]
+                expire = smqs[0]['expire']
+                if order_list[0]['isSelectDiscounts'] == 1:
+                    expire = smqs[0]['expire'] * 2
+                if ubqs.exists():
+                    ubq = ubqs[0]
+                    endTime = CommonService.calcMonthLater(expire, ubq['endTime'])
+                    ub_cqs = UID_Bucket.objects.filter(id=ubq['id']).update \
+                        (uid=UID, channel=channel, bucket_id=bucketId,
+                         endTime=endTime, updateTime=nowTime)
+                    uid_bucket_id = ubq['id']
+                else:
+                    endTime = CommonService.calcMonthLater(expire)
+                    ub_cqs = UID_Bucket.objects.create \
+                        (uid=UID, channel=channel, bucket_id=bucketId, endTime=endTime, addTime=nowTime,
+                         updateTime=nowTime)
+                    uid_bucket_id = ub_cqs.id
+
+                dvq = Device_Info.objects.filter(UID=UID, vodPrimaryUserID='', vodPrimaryMaster='')
+                if dvq.exists():
+                    dvq_set_update_dict = {
+                        'vodPrimaryUserID': userid,
+                        'vodPrimaryMaster': username
+                    }
+                    dvq.update(**dvq_set_update_dict)
+                order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
+                return HttpResponse(WechatPayObject.xml_to_dict({'return_code': 'SUCCESS', 'return_msg': 'OK'}))
+            return HttpResponse(WechatPayObject.xml_to_dict({'return_code': 'FAIL', 'return_msg': '参数格式校验错误'}))
+        except Exception as e:
+            print(repr(e))
+            asy = threading.Thread(target=ModelService.add_log,
+                                   args=('回调',
+                                         '回调报错', repr(e)))
+            asy.start()
+            return response.json(10, repr(e))
+
 
-        if result_code == 'SUCCESS':
-            response = HttpResponse()
-            check_sign = WechatPayObject.get_notifypay(request_dict)
-            if not check_sign:
-                return HttpResponse(WechatPayObject.xml_to_dict({'return_code':'FAIL', 'return_msg':'签名失败'}))
-            orderID = request_dict.get('out_trade_no',None)
-            self.callback_dostatus(orderID)
-            order_qs = Order_Model.objects.filter(orderID=orderID)
-            nowTime = int(time.time())
-            order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts",
-                                         "userID__userID", "userID__username")
-            userid = order_list[0]['userID__userID']
-            username = order_list[0]['userID__username']
-            UID = order_list[0]['UID']
-            channel = order_list[0]['channel']
-            rank = order_list[0]['rank']
-            smqs = Store_Meal.objects.filter(id=rank). \
-                values("day", "bucket_id", "bucket__storeDay", "expire")
-            bucketId = smqs[0]['bucket_id']
-            if not smqs.exists():
-                return HttpResponse(WechatPayObject.xml_to_dict({'return_code':'FAIL', 'return_msg':'套餐不存在'}))
-            # ##
-            ubqs = UID_Bucket.objects.filter(bucket__id=bucketId, uid=UID, channel=channel, endTime__gte=nowTime). \
-                       values("id", "bucket__storeDay", "bucket__region", "endTime").order_by('addTime')[:1]
-            expire = smqs[0]['expire']
-            if order_list[0]['isSelectDiscounts'] == 1:
-                expire = smqs[0]['expire'] * 2
-            if ubqs.exists():
-                ubq = ubqs[0]
-                endTime = CommonService.calcMonthLater(expire,ubq['endTime'])
-                ub_cqs = UID_Bucket.objects.filter(id=ubq['id']).update \
-                    (uid=UID, channel=channel, bucket_id=bucketId,
-                     endTime=endTime, updateTime=nowTime)
-                uid_bucket_id = ubq['id']
-            else:
-                endTime = CommonService.calcMonthLater(expire)
-                ub_cqs = UID_Bucket.objects.create \
-                    (uid=UID, channel=channel, bucket_id=bucketId, endTime=endTime, addTime=nowTime, updateTime=nowTime)
-                uid_bucket_id = ub_cqs.id
 
-            dvq = Device_Info.objects.filter(UID=UID, vodPrimaryUserID='', vodPrimaryMaster='')
-            if dvq.exists():
-                dvq_set_update_dict = {
-                    'vodPrimaryUserID': userid,
-                    'vodPrimaryMaster': username
-                }
-                dvq.update(**dvq_set_update_dict)
-            order_qs.update(status=1, updTime=nowTime, uid_bucket_id=uid_bucket_id)
-            return HttpResponse(WechatPayObject.xml_to_dict({'return_code':'SUCCESS', 'return_msg':'OK'}))
-        return HttpResponse(WechatPayObject.xml_to_dict({'return_code':'FAIL', 'return_msg':'参数格式校验错误'}))
 
     def do_create_pay_order(self, request_dict, userID, ip, response):
         uid = request_dict.get('uid', None)
@@ -1129,13 +1153,13 @@ class CloudStorageView(View):
             notify_url="{SERVER_DOMAIN_SSL}cloudstorage/dowechatnotify".format(
                 SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
             # 获取参数
-            print("进来了,微信支付成功回调")
             response = ResponseObject()
             asy = threading.Thread(target=ModelService.add_log,
                                    args=(orderID,
                                          orderID, '进来了,微信支付创建订单'+notify_url))
             asy.start()
             price = float(price)*100
+            self.callback_dostatus(orderID)
             parameter_dict = pay.get_parameter(orderID, content, price, ip, notify_url)
             print('parameter_dict', parameter_dict)
             # parameter_dict 参数中获取MWEB_URL 调转页面在路径后面添加redirect_url

+ 2 - 2
Controller/EquipmentManagerV3.py

@@ -98,8 +98,8 @@ class EquipmentManagerV3(View):
                         duq = Device_User.objects.filter(userID=userID).values('username')
                         if duq.exists():
                             username = duq[0]['username']
-                            vodPrimaryUserID = username
-                            vodPrimaryMaster = userID
+                            vodPrimaryUserID = userID
+                            vodPrimaryMaster = username
                     try:
                         # 判断是否有用户绑定
                         nowTime = int(time.time())