Exemple #1
0
    def enter(self):
        """
        处理具体业务
        :return: 0/不回包给前端,pb/正确返回,timeout/超时
        """
        try:
            # 验证登录态,某些命令可能不需要登录态,此处做判断
            code, message = verify_session_key(self.numbers, self.session_key)
            if 10400 != code:
                g_log.debug("verify session key failed, %s, %s", code, message)
                return package.error_response(self.cmd, self.seq, 20001, "invalid session key")

            command_handle = {401: self.platform_update_parameters, 402: self.business_parameters_retrieve,
                              403: self.business_parameters_batch_retrieve,
                              404: self.consumption_ratio_update, 405: self.dummy_command,
                              406: self.parameters_record_retrieve}
                              # , 407: self.merchant_recharge,
                              # 408: self.merchant_Withdrawals, 409: self.balance_record_retrieve}
            
            result = command_handle.get(self.cmd, self.dummy_command)()
            if result == 0:
                # 错误或者异常,不回包
                response = 0
            elif result == 1:
                # 错误,且回包
                response = package.error_response(self.cmd, self.seq, self.code, self.message)
            else:
                # 正确,回包
                response = result
            return response
        except Exception as e:
            g_log.error("%s", e)
            return 0
Exemple #2
0
    def enter(self):
        """
        处理具体业务
        :return: 0/不回包给前端,pb/正确返回,timeout/超时
        """
        try:
            # 验证登录态,某些命令可能不需要登录态,此处做判断
            code, message = verify_session_key(self.numbers, self.session_key)
            if 10400 != code:
                g_log.debug("verify session key failed, %s, %s", code, message)
                return package.error_response(self.cmd, self.seq, 70001, "invalid session key")

            command_handle = {701: self.activity_create, 702: self.activity_retrieve, 703: self.dummy_command,
                              704: self.activity_update, 705: self.activity_delete,
                              706: self.consumer_retrieve_activity, 708: self.buy_activity}
            result = command_handle.get(self.cmd, self.dummy_command)()
            if result == 0:
                # 错误或者异常,不回包
                response = 0
            elif result == 1:
                # 错误,且回包
                response = package.error_response(self.cmd, self.seq, self.code, self.message)
            else:
                # 正确,回包
                response = result
            return response
        except Exception as e:
            g_log.error("%s", e)
            return 0
Exemple #3
0
    def enter(self):
        """
        处理具体业务
        :return: 0/不回包给前端,pb/正确返回,timeout/超时
        """
        try:
            # 验证登录态,某些命令可能不需要登录态,此处做判断
            code, message = verify_session_key(self.numbers, self.session_key)
            if 10400 != code:
                g_log.debug("verify session key failed, %s, %s", code, message)
                return package.error_response(self.cmd, self.seq, 80001, "invalid session key")

            command_handle = {801: self.consumer_retrieve_voucher, 802: self.merchant_retrieve_voucher,
                              803: self.confirm_voucher}

            result = command_handle.get(self.cmd, self.dummy_command)()
            if result == 0:
                # 错误或者异常,不回包
                response = 0
            elif result == 1:
                # 错误,且回包
                response = package.error_response(self.cmd, self.seq, self.code, self.message)
            else:
                # 正确,回包
                response = result
            return response
        except Exception as e:
            from print_exception import print_exception
            print_exception()
            g_log.error("%s", e)
            return 0
Exemple #4
0
    def enter(self):
        """
        处理具体业务
        :return: 0/不回包给前端,pb/正确返回,timeout/超时
        """
        try:
            if 508 != self.cmd:     # alipay异步通知
                # 验证登录态,某些命令可能不需要登录态,此处做判断
                code, message = verify_session_key(self.numbers, self.session_key)
                if 10400 != code:
                    g_log.debug("verify session key failed, %s, %s", code, message)
                    return package.error_response(self.cmd, self.seq, 60001, "invalid session key")

            command_handle = {501: self.merchant_credit_flow_retrieve, 502: self.merchant_allow_exchange_in,
                              503: self.merchant_recharge, 504: self.merchant_withdrawals,
                              505: self.balance_record_retrieve, 506: self.balance_retrieve,
                              507: self.recharge_trade_no_retrieve, 508: self.alipay_async_notify}

            result = command_handle.get(self.cmd, self.dummy_command)()
            if result == 0:
                # 错误或者异常,不回包
                response = 0
            elif result == 1:
                # 错误,且回包
                response = package.error_response(self.cmd, self.seq, self.code, self.message)
            else:
                # 正确,回包
                response = result
            return response
        except Exception as e:
            from print_exception import print_exception
            print_exception()
            g_log.error("%s", e)
            return 0