Beispiel #1
0
def addTicketToOuterKZZN2(config, mallBought):
    # global dbObj
    # dbObj = globalVar.getDbObj()
    dbObj = db.db()

    #查询游客信息
    userInfo = False
    if mallBought['identity_info_id'] > 0:
        userInfo = dbObj.select(
            "select user_id, name, mobile, id_number from t_user_identity_info where id = %d"
            % mallBought['identity_info_id'])
    # userInfo = []
    # userInfo.append({
    # 'name': '微景通',
    # 'mobile' : '18523876001'
    # })
    if userInfo == False or len(userInfo) < 1:
        visitorName = '散客'
        visitorMobile = '18523876001'
        idNumber = '110101199003075496'
    else:
        userInfo = userInfo[0]
        visitorMobile = userInfo['mobile']
        visitorName = userInfo['name']
        idNumber = userInfo['id_number']
        # visitorName = repr(visitorName.decode('UTF-8'))[2:-1]
        # visitorName = visitorName.decode('UTF-8')
    # visitorName = 'wjtVisitor'

    ticketName = dbObj.getValue(
        "select name from t_mall_product where id = %d" %
        mallBought['mall_product_id'], 'name')
    ticketName = ticketName.decode('UTF-8')[0:10]
    # ticketName = 'chengrenpiao'
    # ticketName = '成人票'

    planDate = ''
    if mallBought['plan_time']:
        planDate = str(mallBought['plan_time'])[0:10]

    orderInfo = [
        {
            'cid': config['cid']
        },
        {
            'ccipher': config['ccipher']
        },
        # {'CEntrypriseCode': config['CEntrypriseCode']},
        {
            'cOrderID': mallBought['order_number']
        },
        {
            'nTicketType':
            config['mall_nTicketType_' + str(mallBought['mall_product_id'])]
        },
        {
            'cTicketType': ticketName
        },
        {
            'dDateIn': planDate
        },
        {
            'cOtaSource': '微景通'
        },
        {
            'nHumanNum': mallBought['buy_count']
        },
        {
            'cPayType': 'weixin'
        },
        {
            'cCustName': visitorName[0:24]
        },
        {
            'cTel': visitorMobile
        },
        # {'cSecID': str(userInfo['id_number']) + 'X'},
        {
            'cSecID': idNumber
        },
    ]
    data = helper.dict2xml('OnWebOrder', orderInfo,
                           'xmlns="http://127.0.0.1/WebSellWx/"')
    data = ''.join([
        '<?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>' % data, '</soap:Envelope>'
    ])

    # print data;
    # exit();
    processOuterKZZN2(config, mallBought, data, 1)
Beispiel #2
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)
Beispiel #3
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)