Example #1
0
def getOrderDetail(config, orderNo):
    helper.getLog('访问getOrderDetail!!!', 'responseOutCode.HQ2.log')
    url = config['url'] + '?op=OrderFinish'
    headers = hawkAuth(url)
    data = {}
    data['otaCode'] = config['account']
    data['otaOrderNO'] = orderNo
    data['platformSend'] = 0
    parameters = {}
    parameters['type'] = '00'
    parameters['parkCode'] = config['parkCode']
    data['parameters'] = json.dumps(parameters).replace(' ', '')
    sign_str = config['account'] + config['privateKey'] + orderNo + '0' + data[
        'parameters']
    data['sign'] = base64.encodestring(helper.md5(
        sign_str.strip()).upper()).strip()
    postData = '''<?xml version="1.0" encoding="utf-8"?>
            <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                <soap:Body>
                   <OrderFinish xmlns="http://tempuri.org/">
                      <otaCode>%s</otaCode>
                      <otaOrderNO>%s</otaOrderNO>
                      <platformSend>%s</platformSend>
                      <parameters>%s</parameters>
                      <signature>%s</signature>
                    </OrderFinish>
                </soap:Body>
            </soap:Envelope>
       ''' % (config['account'], orderNo, 0, data['parameters'], data['sign'])
    res = helper.httpPost(url, postData, headers)
    resBody = json.loads(
        helper.subStr(res, '<OrderFinishResult>', '</OrderFinishResult>'))
    return resBody
def processOuterJYZY(config, ticketBought, data, processCount):
    dbObj = db.db()
    # 发起同步
    dataOld = data
    data = buildParam(data, config['pkey'], 'createOrderForBeforePaySync')
    re = sendDataToOuterJYZY(config['url'], data)
    # redata, re = sendDataToOuterJYZY(config['url'], None)

    try:
        code = helper.subStr(re, '<code>', '</code>')
        # print responseBody
        # print re
        #成功同步
        if '1000' == code:
            re1 = re
            partnerorderId = helper.subStr(re, '<partnerorderId>', '</partnerorderId>')
            re, postData = payTicketToOuterJYZY(config, ticketBought, partnerorderId)
            # print partnerorderId;exit()

            code = helper.subStr(re, '<code>', '</code>')
            if '1000' == code:
                qrcodeUrl = 'http://pwx.weijingtong.net/index.php/Api/Qrcode/index/?data=' + str(ticketBought['order_detail_id'])
                sql = "update t_ticket_bought set out_app_code = 'JYZY', temp_receiving_code = '%s', receiving_code = '%s', dimen_code_path='%s' where id = %d" %  (ticketBought['receiving_code'], partnerorderId, qrcodeUrl, ticketBought['id'])
                # print sql
                if not True == dbObj.update(sql):
                    helper.getLog(sql, 'addTicketToOuterJYZY.UpdateTicketboughtlistErr.log')
            else:
                re = "re1:%s \nre2:%s \nPostData1:%s \nPostData2:%s" % (re1, re, data, postData)
        else:
            re = "%s \nPostData:%s" % (re, data)
            print 'processCount:' + str(processCount)
            if processCount < 2:
                processCount += 1
                processOuterJYZY(config, ticketBought, dataOld, processCount)
                return
            else:
                re = "%s \nprocessCount:%s" % (re, str(processCount))
    except Exception, e:
        re = str(Exception) + ":" + str(e)
        re = "%s \nPostData:%s" %(re, data)
Example #3
0
def processOuterKZZN2(config, mallBought, data, processCount):
    dbObj = db.db()
    try:
        # 发起同步
        url = config['url']  #http://123.11.226.80:8118/service.asmx
        url = helper.subStr(url, 'http://', '/service')
        host = helper.subStr(url, '', ':')
        port = int(helper.subStr(url, ':', ''))

        responseBody, re = sendDataToOuterKZZN2(host, port, data)

        reBody = helper.subStr(responseBody, '<nStatus>', '</nStatus>')
        # print responseBody
        # print re
        #成功同步
        if '1' == reBody:
            cQrCode = helper.subStr(responseBody, '<cQrCode>', '</cQrCode>')
            cUrl = 'http://' + host + ':' + str(port) + helper.subStr(
                responseBody, '<cUrl>', '</cUrl>')
            cStatus = helper.subStr(responseBody, '<cStatus>', '</cStatus>')
            sql = "update t_mall_bought set out_app_code = 'KZZN2', out_app_no = '%s', dimen_code_path='%s', remark2='%s' where id = '%d'" % (
                cQrCode, cUrl, cStatus, mallBought['id'])
            # sql = "update t_mall_bought set out_app_code = '_WJT', out_app_no = '%s' where id = '%d'" % (mallBought['receiving_code'], mallBought['id'])
            # sql = "update t_ticket_bought set out_app_code = 'KZZN2', temp_receiving_code = '%s', receiving_code = '%s', dimen_code_path='%s', remark2='%s' where id = %d" %  (mallBought['receiving_code'], cQrCode, cUrl, cStatus, mallBought['id'])
            # print sql
            # print mallBought
            if not True == dbObj.update(sql):
                helper.getLog('update t_mall_bought error:' + sql,
                              'mall.kzzn2.log')

            # 发送消息
            textMessage = '微景通验证码:' + mallBought[
                'receiving_code'] + ' \n票务验证码:' + cQrCode + ' \n购票张数:' + str(
                    mallBought['buy_count']) + ' \n购票时间:' + str(
                        mallBought['create_time'])
            time = int(helper.thisTime())
            re = re + "\nsendMessageToUser:"******"%s \nPostData:%s" % (re, data)
            # print 'processCount:' + str(processCount)
            if processCount < 2:
                processCount += 1
                processOuterKZZN2(config, mallBought, data, processCount)
                return
            else:
                re = "%s \nprocessCount:%s" % (re, str(processCount))
    except Exception, e:
        re = str(Exception) + ":" + str(e)
        re = "%s \nPostData:%s" % (re, data)
Example #4
0
def sendDataToOuterHQ2(config, data):
    helper.getLog('访问sendDataToOuterHQ2!!!', 'responseOutCode.HQ2.log')
    url = config['url'] + '?op=OrderOccupies'

    headers = hawkAuth(url)
    data = '''<?xml version="1.0" encoding="utf-8"?>
            <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
            <soap:Body>
               <OrderOccupies xmlns="http://tempuri.org/">
                   <merchantCode>%s</merchantCode>
                   <postOrder>%s</postOrder>
                   <signature>%s</signature>
                </OrderOccupies>
            </soap:Body>
        </soap:Envelope>
       ''' % (data['merchantCode'], data['postOrder'], data['signature'])
    res = helper.httpPost(url, data, headers)
    resBody = json.loads(
        helper.subStr(res, '<OrderOccupiesResult>', '</OrderOccupiesResult>'))
    return resBody
def payTicketToOuterJYZY(config, ticketBought, partnerorderId, count = 1):
    url = config['url']
    data = '''<?xml version="1.0" encoding="UTF-8"?>
        <request xsi:schemaLocation="http://piao.qunar.com/2013/QMenpiaoRequestSchema QMRequestDataSchema-2.0.1.xsd" xmlns="http://piao.qunar.com/2013/QMenpiaoRequestSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <header>
                <application>Qunar.Menpiao.Agent</application>
                <processor>SupplierDataExchangeProcessor</processor>
                <version>v2.0.1</version>
                <bodyType>PayOrderForBeforePaySyncRequestBody</bodyType>
                <createUser>SupplierSystemName</createUser>
                <createTime>%s</createTime>
                <supplierIdentity>%s</supplierIdentity>
            </header>
            <body xsi:type="PayOrderForBeforePaySyncRequestBody">
                <orderInfo>
                    <partnerOrderId>%s</partnerOrderId>
                    <orderStatus>PREPAY_ORDER_PRINTING</orderStatus>
                    <orderPrice>%s</orderPrice>
                    <paymentSerialno></paymentSerialno>
                    <eticketNo></eticketNo>
                </orderInfo>
            </body>
        </request>
        ''' % ( helper.now(), config['uid'], partnerorderId, ticketBought['count']*ticketBought['price']*100 )

    data = data.replace("\n", '')
    data = buildParam(data, config['pkey'], 'payOrderForBeforePaySync');
    # print data;

    re = sendDataToOuterJYZY(url, data)

    code = helper.subStr(re, '<code>', '</code>')
    if( count < 2 and  '1000' != code ):
       re, data = payTicketToOuterJYZY(config, ticketBought, partnerorderId, 2)
       data = data + "\nprocessCount:2"

    return [re, data]
Example #6
0
def addTicketToOuterSZZWY(config, ticketBought):
    # global dbObj
    # dbObj = globalVar.getDbObj()
    dbObj = db.db()

    #查询游客信息
    # userInfo = ''
    userInfo = dbObj.select(
        "select user_id, name, mobile from t_user_identity_info where id = %d"
        % ticketBought['identity_info_id'])
    if userInfo == False or len(userInfo) < 1:
        visitorName = 'wjtVisitor'
        visitorMobile = '18523876001'
    else:
        userInfo = userInfo[0]
        visitorName = userInfo['user_id']
        visitorMobile = userInfo['mobile']

    products = [{
        'viewid': config['viewid_' + str(ticketBought['ticket_id'])]
    }, {
        'Viewname': ticketBought['ticket_id']
    }, {
        'Type': config['Type_' + str(ticketBought['ticket_id'])]
    }, {
        'number': ticketBought['count']
    }]

    orderInfo = [
        {
            'TimeStamp': helper.now()
        },
        {
            'CompanyCode': config['CompanyCode']
        },
        {
            'CompanyName': 'weijingtong'
        },
        {
            'CompanyOrderID': ticketBought['order_id']
        },
        {
            'OrderTime': ticketBought['create_time']
        },
        {
            'ArrivalDate': ticketBought['plan_time']
        },
        {
            'PayType': 1
        },
        {
            'VisitorName': visitorName
        },
        {
            'VisitorMobile': visitorMobile
        },
        {
            'IdCardNeed': 0
        },
        {
            'IdCard': '1X'
        },
        {
            'Note': 'weijingtong'
        },
        {
            'Products':
            helper.dict2xml('product',
                            products).replace('<',
                                              '&lt;').replace('>', '&gt;')
        },
    ]
    data = helper.dict2xml('OrderInfo', orderInfo)
    data = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><OrderReq xmlns="http://tempuri.org/">%s</OrderReq></soap:Body></soap:Envelope>' % data
    # data = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><OrderReq xmlns="http://tempuri.org/"><OrderInfo><TimeStamp>2017-02-21 19:41:29</TimeStamp><CompanyCode>weijingtong96325812zfr</CompanyCode><CompanyName>weijingtong</CompanyName><CompanyOrderID>225534</CompanyOrderID><OrderTime>2017-02-21 19:34:33</OrderTime><ArrivalDate>2017-02-21 00:00:00</ArrivalDate><PayType>1</PayType><VisitorName>oZ9oauAoKfN1C4OptkqQbSeXhW-k</VisitorName><VisitorMobile>18723012341</VisitorMobile><IdCardNeed>0</IdCardNeed><IdCard>1X</IdCard><Note>weijingtong</Note><Products>&lt;product&gt;&lt;viewid&gt;E03&lt;/viewid&gt;&lt;Viewname&gt;2649&lt;/Viewname&gt;&lt;Type&gt;Adult&lt;/Type&gt;&lt;number&gt;1&lt;/number&gt;&lt;/product&gt;</Products></OrderInfo></OrderReq></soap:Body></soap:Envelope>'
    # data = '''<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/"><SOAP-ENV:Body><ns1:OrderReq><ns1:OrderInfo><ns1:TimeStamp>2017-02-21 15:34:49</ns1:TimeStamp><ns1:CompanyCode>weijingtong96325812zfr</ns1:CompanyCode><ns1:CompanyName>weijingtong</ns1:CompanyName><ns1:CompanyOrderID>186738</ns1:CompanyOrderID><ns1:OrderTime>2017-02-21 15:34:49</ns1:OrderTime><ns1:ArrivalDate>2017-02-21</ns1:ArrivalDate><ns1:PayType>1</ns1:PayType><ns1:VisitorName>WeijingtongVisitor</ns1:VisitorName><ns1:VisitorMobile>18523876001</ns1:VisitorMobile><ns1:IdCardNeed>0</ns1:IdCardNeed><ns1:IdCard>1X</ns1:IdCard><ns1:Products>&lt;product&gt;&lt;viewid&gt;E03&lt;/viewid&gt;&lt;Type&gt;Adult&lt;/Type&gt;&lt;number&gt;1&lt;/number&gt;&lt;viewname&gt;21&lt;/viewname&gt;&lt;/product&gt;</ns1:Products></ns1:OrderInfo></ns1:OrderReq></SOAP-ENV:Body></SOAP-ENV:Envelope>'''
    # data = '''<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/"><SOAP-ENV:Body><ns1:OrderCancel><ns1:orderInfo><ns1:TimeStamp>2017-02-21 19:39:50</ns1:TimeStamp><ns1:CompanyCode>weijingtong96325812zfr</ns1:CompanyCode><ns1:CompanyOrderID>186749</ns1:CompanyOrderID><ns1:IdCardNeed>0</ns1:IdCardNeed></ns1:orderInfo></ns1:OrderCancel></SOAP-ENV:Body></SOAP-ENV:Envelope>'''
    # print data;exit()

    try:
        # 发起同步
        url = config[
            'url']  #http://ydpt.hdyuanmingxinyuan.com/interface/AgentInterface.asmx
        host = helper.subStr(url, 'http://', '/interface')

        webservice = httplib.HTTPConnection(host, 80, timeout=50)
        # webservice.set_debuglevel(1)

        # print response.getheaders() #获取头信息
        #连接到服务器后的第一个调用。它发送由request字符串到到服务器
        webservice.putrequest("POST", "/interface/AgentInterface.asmx")
        # webservice.putheader("Accept-Encoding", "text")
        # webservice.putheader("Host", "ydpt.hdyuanmingxinyuan.com")
        webservice.putheader("User-Agent", "WeijingtongService-python")
        webservice.putheader("Content-Type", "text/xml; charset=utf-8")
        # webservice.putheader("Connection", "Keep-Alive")
        webservice.putheader("Content-Length", "%d" % len(data))
        webservice.putheader("SOAPAction", "\"http://tempuri.org/OrderReq\"")
        # webservice.putheader("SOAPAction", "\"http://tempuri.org/OrderCancel\"")
        #发送空行到服务器,指示header的结束
        webservice.endheaders()
        #发送报文数据到服务器
        webservice.send(data)
        #获取返回HTTP 响应信息
        response = webservice.getresponse()
        responseBody = response.read()
        # print 'response:'
        # print response.read()
        # exit()
        res = []
        res.append('HttpStatus:' + str(response.status))
        res.append('HttpReason:' + response.reason)
        res.append('HttpBody:' + responseBody)
        head = []
        for header in response.getheaders():
            head.append('%s: %s' % (header[0], header[1]))

        head = "\n".join(head)
        res.append('HttpHeader:' + head)  #获取头信息
        # print res
        # exit()
        re = "\n".join(res)
        # re = re.decode('gb2312').encode('utf-8')

        webservice.close()  #关闭链接

        #成功同步
        if 'true' == helper.subStr(responseBody, '<Result>', '</Result>'):
            sql = "update t_ticket_bought set out_app_code = 'YMXY', temp_receiving_code = 'None' where id = %d" % ticketBought[
                'id']
            if not True == dbObj.update(sql):
                helper.getLog(
                    sql, 'addTicketToOuterYMXY.UpdateTicketboughtlistErr.log')
        pass
    except Exception, e:
        re = str(Exception) + ":" + str(e)
        re = "%s \npostdata:%s" % (re, data)
Example #7
0
def addTicketToOuterDK(config, ticketBought):
    # global dbObj
    # dbObj = globalVar.getDbObj()
    dbObj = db.db()

    #查询游客信息
    # userInfo = ''
    userInfo = dbObj.select(
        "select user_id, name, mobile, id_number from t_user_identity_info where id = %d"
        % ticketBought['identity_info_id'])
    # userInfo = []
    # userInfo.append({
    # 'name': '微景通',
    # 'mobile' : '18523876001'
    # })
    if userInfo == False or len(userInfo) < 1:
        visitorName = 'weijingtongVisitor'
        visitorMobile = '18523876001'
    else:
        userInfo = userInfo[0]
        visitorMobile = userInfo['mobile']
        ##        visitorName = userInfo['user_id']
        visitorName = userInfo['name']
        visitorName = repr(visitorName.decode('UTF-8'))[2:-1]
##        visitorName = '\u5f20\u8001\u5927'
##        visitorName = urllib.urlencode({1:visitorName})[2:]

# visitorName = 'wjtVisitor'
    ticketName = dbObj.getValue(
        "select name from t_ticket where id = %d" % ticketBought['ticket_id'],
        'name')
    # ticketName = '成人票'
    ticketName = repr(ticketName.decode('UTF-8'))[2:-1][0:48]
    # ticketName = 'test'
    Order = {}
    Order['OrderNO'] = str(ticketBought['order_detail_id'])
    Order['LinkName'] = visitorName
    Order['LinkPhone'] = visitorMobile
    Order['LinkICNO'] = userInfo['id_number']
    Order['TotalAmount'] = str(
        round(ticketBought['price'] * ticketBought['count'], 2))
    Order['CreateTime'] = str(ticketBought['create_time'])

    Visitor = {}
    Visitor['VisitorName'] = visitorName
    Visitor['VisitorPhone'] = visitorMobile
    Visitor['VisitorICNO'] = userInfo['id_number']

    Details = {}
    Details['OrderNO'] = ticketBought['order_detail_id']
    Details['ItemID'] = ticketBought['order_detail_id']
    Details['ProductCode'] = config['ProductCode_' +
                                    str(ticketBought['ticket_id'])]
    Details['ProductID'] = config['ProductID_' +
                                  str(ticketBought['ticket_id'])]
    Details['ProductPackID'] = config['ProductPackID_' +
                                      str(ticketBought['ticket_id'])]
    Details['ProductMarketPrice'] = str(round(ticketBought['list_price'], 2))
    Details['ProductPrice'] = str(round(ticketBought['price'], 2))
    Details['ProductSellPrice'] = str(round(ticketBought['price'], 2))
    Details['ProductCount'] = ticketBought['count']
    Details['ProductSDate'] = str(ticketBought['plan_time'])[0:10]
    Details['ProductEDate'] = str(ticketBought['plan_time'])[0:10]
    Details['Visitor'] = json.dumps(Visitor)

    postOrder = {}
    postOrder['Ptime'] = helper.now()
    postOrder['parkCode'] = config['parkCode']
    postOrder['timestamp'] = helper.now()
    postOrder['Order'] = json.dumps(Order)
    postOrder['Details'] = json.dumps([Details])

    # print postOrder
    # print json.dumps(postOrder)
    postOrder = json.dumps(postOrder)
    # exit()
    sign = base64.encodestring(
        helper.md5(config['merchantCode'] + config['privateKey'] + postOrder +
                   str(int(helper.thisTime()))).upper()).strip()
    # sign = '1'
    # print sign;exit()

    data = '''<?xml version="1.0" encoding="utf-8"?>
            <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                <soap:Body>
                    <OrderOccupies xmlns="http://tempuri.org/">
                          <merchantCode>%s</merchantCode>
                          <postOrder>%s</postOrder>
                          <signature>%s</signature>
                    </OrderOccupies>
                </soap:Body>
            </soap:Envelope>''' % (config['merchantCode'], postOrder, sign)
    # print data;
    # exit();
    try:
        # 发起同步
        '''
        responseBody = helper.httpPost(config['url'] + '/OrderOccupies', data, {'Content-Type' : 'application/x-www-form-urlencoded'})
        '''
        url = config['url']  #http://123.11.226.80:8118/service.asmx
        # url  = 'http://112.74.131.57:10006/service.asmx'
        host = helper.subStr(url, 'http:/', 'service')
        host = helper.subStr(host, '/', ':')
        port = helper.subStr(url, '://', 'service')
        port = helper.subStr(port, ':', '/')
        # print host;exit()

        #占用定单
        res = helper.webservice(host, int(port), "/service.asmx", data,
                                "http://tempuri.org/OrderOccupies", 0)
        responseBody = res[0]
        re = res[1]
        reBody = json.loads(
            helper.subStr(responseBody, '<OrderOccupiesResult>',
                          '</OrderOccupiesResult>'))
        # print reBody
        #成功同步
        if '00' == reBody['ResultCode']:
            #支付定单
            parameters = {}
            parameters['otaOrderNO'] = str(ticketBought['order_detail_id'])
            parameters['parkCode'] = config['parkCode']
            parameters['timestamp'] = helper.now()
            parameters = json.dumps(parameters)

            sign = base64.encodestring(
                helper.md5(config['merchantCode'] + config['privateKey'] +
                           parameters +
                           str(int(helper.thisTime()))).upper()).strip()

            data2 = '''<?xml version="1.0" encoding="utf-8"?>
                    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                        <soap:Body>
                            <OrderFinish xmlns="http://tempuri.org/">
                              <otaCode>%s</otaCode>
                              <parameters>%s</parameters>
                              <signature>%s</signature>
                            </OrderFinish>
                        </soap:Body>
                    </soap:Envelope>''' % (config['merchantCode'], parameters,
                                           sign)

            res = helper.webservice(host, int(port), "/service.asmx", data2,
                                    "http://tempuri.org/OrderFinish", True)
            responseBody2 = res[0]
            re2 = res[1]
            reBody = json.loads(
                helper.subStr(responseBody2, '<OrderFinishResult>',
                              '</OrderFinishResult>'))
            # print reBody
            if '00' == reBody['ResultCode']:
                re = re + "\n\n" + re2
                #生成二维码
                resultJson = json.loads(reBody['ResultJson'])[0]
                qrcodeImg = 'http://pwx.weijingtong.net/index.php/Api/Qrcode/?data=' + resultJson[
                    'ECode']
                sql = "update t_ticket_bought set out_app_code = 'DK', temp_receiving_code = '%s', receiving_code='%s', dimen_code_path = '%s' where id = %d" % (
                    ticketBought['receiving_code'], resultJson['ECode'],
                    qrcodeImg, ticketBought['id'])
                # print sql
                if not True == dbObj.update(sql):
                    helper.getLog(
                        sql,
                        'addTicketToOuterDK.UpdateTicketboughtlistErr.log')
            else:
                re = "%s\nPostData1:%s\n\n%s\nPostData2:%s" % (re, data, re2,
                                                               data2)
                pass

        else:
            re = "%s \nPostData:%s" % (re, data)
            pass
    except Exception, e:
        re = str(Exception) + ":" + str(e)
        re = "%s \nPostData:%s" % (re, data)
Example #8
0
def addTicketToOuterKZZN(config, ticketBought):
    # global dbObj
    # dbObj = globalVar.getDbObj()
    dbObj = db.db()

    #查询游客信息
    # userInfo = ''
    userInfo = dbObj.select("select user_id, name, mobile, id_number from t_user_identity_info where id = %d" % ticketBought['identity_info_id'])
    # userInfo = []
    # userInfo.append({
        # 'name': '微景通',
        # 'mobile' : '18523876001'
    # })
    if userInfo == False or len(userInfo) < 1:
        visitorName = 'weijingtongVisitor'
        visitorMobile = '18523876001'
    else:
        userInfo = userInfo[0]
        visitorMobile = userInfo['mobile']
##        visitorName = userInfo['user_id']
        visitorName = userInfo['name']
        visitorName = repr(visitorName.decode('UTF-8'))[2:-1]
##        visitorName = '\u5f20\u8001\u5927'
##        visitorName = urllib.urlencode({1:visitorName})[2:]

    # visitorName = 'wjtVisitor'
    ticketName = dbObj.getValue("select name from t_ticket where id = %d" % ticketBought['ticket_id'], 'name')
    # ticketName = '成人票'
    ticketName = repr(ticketName.decode('UTF-8'))[2:-1][0:48]
    # ticketName = 'test'
    orderInfo = [
        {'cid': config['cid']},
        {'ccipher': config['ccipher']},
        {'cOrder': ticketBought['order_detail_id']},
        {'nHuman': ticketBought['count']},
        {'cName': visitorName[0:24]},
        {'cPhone': visitorMobile},
        {'nTicketType': config['nTicketType_' + str(ticketBought['ticket_id'])]},
        {'cTicketType': ticketName},
        {'dDateIn': str(ticketBought['plan_time'])[0:10]},
        {'cQrID': ticketBought['receiving_code']},
        {'nCustType': 1},
        {'cip': socket.gethostbyname(socket.gethostname())},
        {'fMoney': ticketBought['price']},
        {'cPayType': 'weixin'},
    ]
    data = helper.dict2xml('OnPreSellOrder', orderInfo, 'xmlns="http://localhost/WebSell/"')
    data = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body>%s</soap:Body></soap:Envelope>' % data

    # print data;
    # exit();

    try:
        # 发起同步
        url = config['url']   #http://123.11.226.80:8118/service.asmx
        host = helper.subStr(url, 'http:/', 'service')
        host = helper.subStr(host, '/', ':')
        # print host
        webservice = httplib.HTTPConnection(host, 8118, timeout = 50)
        # webservice.set_debuglevel(1)

        # print response.getheaders() #获取头信息
        #连接到服务器后的第一个调用。它发送由request字符串到到服务器
        webservice.putrequest("POST", "/service.asmx")
        # webservice.putheader("Accept-Encoding", "text")
        # webservice.putheader("Host", "123.11.226.80")
        webservice.putheader("User-Agent", "WeijingtongService-python")
        webservice.putheader("Content-Type", "text/xml; charset=utf-8")
        # webservice.putheader("Connection", "Keep-Alive")
        webservice.putheader("Content-Length", "%d" % len(data))
        webservice.putheader("SOAPAction", '"http://localhost/WebSell/OnPreSellOrder"')
        # webservice.putheader("SOAPAction", '"http://tempuri.org/OnPreSellOrder"')
        # webservice.putheader("SOAPAction", '"http://123.11.226.80/OnPreSellOrder"')
        #发送空行到服务器,指示header的结束
        webservice.endheaders()
        #发送报文数据到服务器
        webservice.send(data)
        #获取返回HTTP 响应信息
        response = webservice.getresponse()
        responseBody = response.read()
        # print 'response:'
        # print response.read()
        # exit()
        res = []
        res.append('ReHttpStatus:' + str( response.status ))
        res.append('ReHttpReason:' + response.reason)
        res.append('ReHttpBody:' + responseBody)
        head = []
        for header in response.getheaders():
            head.append('%s: %s' % ( header[0], header[1] ))

        head = "\n".join(head)
        res.append('ReHttpHeader:' + head) #获取头信息
        # print res
        # exit()
        re = "\n".join(res)
        # re = re.decode('gb2312').encode('utf-8')

        webservice.close() #关闭链接

        reBody = helper.subStr(responseBody, '<OnPreSellOrderResult>', '</OnPreSellOrderResult>')
        # print reBody
        #成功同步
        if '1' == reBody:
            #生成二维码
            reMakeQrcode = helper.httpGet( helper.confGet('host', 'commonService') + 'Api/TicketQrcode/saveFile/?clientId=' + str( ticketBought['client_id'] ) + '&receivingCode=' + ticketBought['receiving_code'] )
            reMakeQrcodeMap = json.loads(reMakeQrcode)
            # print reMakeQrcodeMap['code']
            if reMakeQrcodeMap['code'] == 0:
                sql = "update t_ticket_bought set out_app_code = 'KZZN', temp_receiving_code = '%s', dimen_code_path = '%s' where id = %d" %  (ticketBought['receiving_code'], reMakeQrcodeMap['filePath'], ticketBought['id'])
                # print sql
                if not True == dbObj.update(sql):
                    helper.getLog(sql, 'addTicketToOuterKZZN.UpdateTicketboughtlistErr.log')
        else:
            re = "%s \nPostData:%s" % (re, data)
            pass
    except Exception, e:
        re = str(Exception) + ":" + str(e)
        re = "%s \nPostData:%s" %(re, data)