def getOrderListBySupplierIdAndDate(supplierId, dateStr):
    dbtool = DBTool(host='172.16.16.9',
                    port=3306,
                    username='******',
                    password='******',
                    db='trade')
    res = dbtool.execute_sql(
        "select order_id from t_order_merch where order_id in (select transaction_id from t_voucher_base where supplier_id='%s' and start_time='%s 00:00:00') and merch_state=0"
        % (supplierId, dateStr))
    return res
def getOrderList(contacteeTag):
    dbtool = DBTool(host='172.16.16.9',
                    port=3306,
                    username='******',
                    password='******',
                    db='trade')
    sql = "select DISTINCT(order_id) from t_order_merch where order_id in (select order_id from t_order where contactee='%s') and merch_state=0" % contacteeTag
    logging.info(sql)
    res = dbtool.execute_sql(sql)
    return res
def checkTicket(orderIdList, macIds, percentRate=0.5, percentCheckRate=1.0):
    dbtool = DBTool(host='172.16.16.9',
                    port=3306,
                    username='******',
                    password='******',
                    db='trade')
    # time.sleep(10)
    maxMacLen = len(macIds) - 1
    looplen = int(float(len(orderIdList)) * percentRate)
    print looplen
    logging.info("全部订单数量%d,退款比例%f,实际应退款单数:%d。" %
                 (len(orderIdList), percentRate, looplen))
    totalCount = 0
    failCount = 0
    passCount = 0
    for i in range(0, looplen):
        logging.info('-=====OrderID:::--' + str(orderIdList[i][0]) +
                     '=========尝试检票。。。=========')
        sql = """SELECT voucher_content from t_voucher_base where transaction_id = '%s' """ % orderIdList[
            i][0]
        data = dbtool.execute_sql(sql)
        logging.info(sql)
        lenCheck = int(float(len(data)) * percentCheckRate)
        for j in range(0, lenCheck):
            try:
                indexMac = random.randint(0, maxMacLen)
                macId = macIds[indexMac]
                url = "http://voucher.stage.mftour.net/ticketService/QueryOrders?macId=%s&voucherContent=%s" % (
                    macId, data[j][0])
                logging.info(url)
                getOrderDetailByReseller = requests.get(url=url, timeout=10)
                logging.info(getOrderDetailByReseller.text)
                queryOeders = json.loads(getOrderDetailByReseller.text)
                ticketURL = ''
                totalCount += 1
                ticketURL = """ http://voucher.stage.mftour.net/ticketService/checkVoucher?macId=%s&voucherIds=%s""" % (
                    macId, queryOeders['voucherList'][0]['voucherId'])
                logging.info(ticketURL)
                checkTicketDevice = requests.get(url=ticketURL, timeout=10)
                retText = checkTicketDevice.text
                retdict = json.loads(retText)
                logging.info(retText)
                if retdict['code'] == '0001':
                    logging.info("检票成功")
                    passCount += 1
                else:
                    logging.info("检票失败")
                    failCount += 1
            except Exception, e:
                logging.info(e)
                logging.info("检票失败")
                failCount += 1
        logging.info("共检票%d,成功%d,失败%d。" % (totalCount, passCount, failCount))
Ejemplo n.º 4
0
def checkTicket(cardIds):
    dbtool = DBTool(host='172.16.16.9',
                    port=3306,
                    username='******',
                    password='******',
                    db='trade')

    # time.sleep(10)
    for i in range(0, len(cardIds)):
        print '------------' + str(cardIds[i]) + '====================='
        data = dbtool.execute_sql(
            """SELECT voucher_content from t_voucher_base where transaction_id = '%s' """
            % cardIds[i])

        for j in range(0, len(data)):

            url = "http://fhgc.stage.piaozhijia.com/ticketService/QueryOrders?macId=863789020447557&cardId=%s" % (
                data[j])
            print url

            getOrderDetailByReseller = requests.get(url=url, timeout=10)
            print getOrderDetailByReseller.text
            queryOeders = json.loads(getOrderDetailByReseller.text)
            ticketURL = ''
            try:
                ticketURL = """ http://fhgc.stage.piaozhijia.com/ticketService/checkTicketDevice?ticketData={"request_macid":%%20"863789020447557", "child_product_id":"%s", "ticket_id":"%s", "is_group":"2"}""" % (
                    queryOeders['responseBody'][0]['child_product_list'][0]
                    ['child_product_id'],
                    queryOeders['responseBody'][0]['ticket_id'])
                print ticketURL
                checkTicketDevice = requests.get(url=ticketURL, timeout=10)
                print checkTicketDevice.text
            except Exception, e:
                print e
                print ticketURL

                print getOrderDetailByReseller.text
Ejemplo n.º 5
0
            testenv = "test"

    except Exception, e:
        print "No args. Use default!"
        logLevel = 'DEBUG'
        testenv = 'test'

    if UsualTools.isWindowsSystem():
        print u"windows不能运行任务取消!"
    elif UsualTools.isMacOS():
        print u"macOS不能运行任务取消!"

    ##################################################################################################
    #初始化数据库配置conf
    sc = ServiceConf(testenv)
    db = DBTool(sc.dbhost, sc.dbport, sc.dbusername, sc.dbpassword, sc.dbname)

    conf_path = ""
    if UsualTools.isLinuxSystem():  #正式环境
        conf_path = "/home"
    elif UsualTools.isWindowsSystem():  #王吉亮测试环境
        conf_path = "D:/devcodes/DubboInterfaceTestFramework/DubboInterfaceTestFramework"
    elif UsualTools.isMacOS():  #liyaochao测试环境
        conf_path = "/home"

    commonRetCode, commnonConfig = getConfFromDB(db,
                                                 "commonconf",
                                                 confPath=conf_path +
                                                 "/taskCancelcommonconf.conf")
    commonDict = commnonConfig.conf_dict
    db.release()
Ejemplo n.º 6
0
        logLevel = 'DEBUG'
        testenv = 'test'

    if UsualTools.isWindowsSystem():
        print u"windows 只能运行测试环境!"
        logLevel = 'DEBUG'
        testenv = 'test'
    elif UsualTools.isMacOS():
        print u"macOS 只能运行测试环境!"
        logLevel = 'DEBUG'
        testenv = 'test'

    ##################################################################################################
    #初始化数据库配置conf
    sc = ServiceConf(testenv)
    db = DBTool(sc.dbhost, sc.dbport, sc.dbusername, sc.dbpassword, sc.dbname)

    conf_path = ""
    if UsualTools.isLinuxSystem():  #正式环境
        conf_path = "/home"
    elif UsualTools.isWindowsSystem():  #王吉亮测试环境
        conf_path = "D:/devcodes/DubboInterfaceTestFramework/DubboInterfaceTestFramework"
    elif UsualTools.isMacOS():  #liyaochao测试环境
        conf_path = "/home"

    # =================获取所有配置======================
    confSql = "select confName,confText from tb_conf where state=1 "
    confRes = db.execute_sql(confSql)
    confDict = {}
    for res in confRes:
        tmpConfKey = res[0]
            testenv = "test"

    except Exception, e:
        print "No args. Use default!"
        logLevel = 'DEBUG'
        testenv = 'test'

    if UsualTools.isWindowsSystem():
        print u"windows不能运行任务取消!"
    elif UsualTools.isMacOS():
        print u"macOS不能运行任务取消!"

    ##################################################################################################
    # 初始化数据库配置conf
    sc = ServiceConf(testenv)
    db = DBTool(sc.dbhost, sc.dbport, sc.dbusername, sc.dbpassword, sc.dbname)

    conf_path = ""
    if UsualTools.isLinuxSystem():  # 正式环境
        conf_path = "/home"
    elif UsualTools.isWindowsSystem():  # 王吉亮测试环境
        conf_path = "D:/devcodes/DubboInterfaceTestFramework/DubboInterfaceTestFramework"
    elif UsualTools.isMacOS():  # liyaochao测试环境
        conf_path = "/home"

    commonRetCode, commnonConfig = getConfFromDB(db,
                                                 "commonconf",
                                                 confPath=conf_path +
                                                 "/taskCancelcommonconf.conf")
    commonDict = commnonConfig.conf_dict
    db.release()
def rerundOrder(orderIdList, percentOrder=0.1):
    s = requests.session()
    host = "http://saas.stage.mftour.net"
    url = "/saas/login/doLogin"
    headers = {
        "User-Agent":
        "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
    }
    final_param = ['username', ''], ['password', '']
    final_param[0][1] = "fhgc002"
    final_param[1][1] = "123456"
    retres = s.post(url="%s%s" % (host, url),
                    data=final_param,
                    headers=headers,
                    timeout=10)
    token_url = "/saas/login/menus"
    retres = s.post(url="%s%s" % (host, token_url), timeout=10)
    looplen = int(float(len(orderIdList)) * percentOrder)
    logging.info("全部订单数量%d,退款比例%f,实际应退款单数:%d。" %
                 (len(orderIdList), percentOrder, looplen))
    dbtool = DBTool(host='172.16.16.9',
                    port=3306,
                    username='******',
                    password='******',
                    db='trade')
    totalCount = 0
    failCount = 0
    passCount = 0
    for i in range(0, looplen):
        totalCount += 1
        orderId = orderIdList[i][0]
        sqlrefund = "select merch_id from t_order_merch where order_id='%s'" % orderId
        refundIdList = dbtool.execute_sql(sqlrefund)
        print refundIdList
        refundId = refundIdList[0][0]

        host = "http://saas.stage.mftour.net"
        url = "/saas/orders/refund"
        headers = {
            "User-Agent":
            "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0"
        }
        final_param = ['orderId', ''], ['refundIdsAndNums',
                                        ''], ['content', '']
        final_param[0][1] = orderId
        final_param[1][1] = "%s,1" % refundId
        final_param[2][1] = "testrefundbywjl"
        retres = s.post(url="%s%s" % (host, url),
                        data=final_param,
                        headers=headers,
                        timeout=10)
        retstr = retres.text
        try:
            retdict = json.loads(retstr.strip())
            if retdict['code'] == "0000":
                print "退款成功"
                passCount += 1
            else:
                print "退款失败"
                print retstr
                failCount += 1
        except Exception, e:
            print e
            print "退款失败"
            print retstr
            failCount += 1
Ejemplo n.º 9
0
        logLevel = 'DEBUG'
        testenv = 'test'

    if UsualTools.isWindowsSystem():
        print u"windows 只能运行测试环境!"
        logLevel = 'DEBUG'
        testenv = 'test'
    elif UsualTools.isMacOS():
        print u"macOS 只能运行测试环境!"
        logLevel = 'DEBUG'
        testenv = 'test'

    ##################################################################################################
    #初始化数据库配置conf
    sc = ServiceConf(testenv)
    db = DBTool(sc.dbhost, sc.dbport, sc.dbusername, sc.dbpassword, sc.dbname)

    conf_path = ""
    if UsualTools.isLinuxSystem():#正式环境
        conf_path = "/home"
    elif UsualTools.isWindowsSystem(): #王吉亮测试环境
        conf_path = "D:/devcodes/DubboInterfaceTestFramework/DubboInterfaceTestFramework"
    elif UsualTools.isMacOS(): #liyaochao测试环境
        conf_path = "/home"

    #=================获取所有配置======================
    confSql = "select confName,confText from tb_conf where state=1 "
    confRes = db.execute_sql(confSql)
    confDict = {}
    for res in confRes:
        tmpConfKey = res[0];
Ejemplo n.º 10
0
from Config.Config import Config

if __name__ == "__main__":
    if UsualTools.isLinuxSystem():
        logging.basicConfig(
            level='INFO',
            format=
            '%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
            datefmt='%a, %d %b %Y %H:%M:%S',
            filename='/home/InterfaceFrameworkOnline/logs/runtask.log',
            filemode='w')
        # 循环遍历t_task表,顺序执行任务,执行时把state变成2,执行后变成3.
        conf = Config("../ConfFile/platform.conf").conf_dict
        while True:
            db = DBTool(conf['db']['host'], int(conf['db']['port']),
                        conf['db']['username'], conf['db']['password'],
                        conf['db']['dbname'])
            results = db.execute_sql(
                "select * from tb_taskpython where state=1 or state=2 order by create_time asc"
            )
            for res in results:
                logging.info(u"执行命令:%s" % res[1])
                sqlupdate = "update tb_taskpython set state=2 where id=%d" % res[
                    0]
                db.execute_sql(sqlupdate)
                message = subprocess.Popen(res[1],
                                           shell=True,
                                           stdout=subprocess.PIPE,
                                           stderr=subprocess.STDOUT)
                out, err = message.communicate()
                outresult = ""