Ejemplo n.º 1
0
def copy_tradenum(order_list):
    for i in order_list:
        module = DbUtil.get_mod_16(DbUtil.get_module_by_order_code(i))
        table_index = DbUtil.get_mode_64(DbUtil.get_module_by_order_code(i))
        db_url = DbUtil.get_db_ip(module)

        db = pymysql.connect(db_url, "root", "Aa123456", "sibu_directsale")
        cursor = db.cursor()
        sql = "SELECT t.trade_id\
              FROM sibu_directsale_order_log_%s.trade_log_%s t \
              WHERE t.order_code = '%s' ORDER BY create_date ASC  LIMIT 1" % (
            module, table_index, i)
        cursor.execute(sql)
        result = cursor.fetchone()
        if result is None:
            print("failed: trade is none")
            continue
        elif result[0] is None or str(result[0]).startswith("T"):
            print("failed: " + i + "-" + result[0])
            continue

        sql = "UPDATE sibu_directsale_order_%s.doing_order_%s o SET o.payment_number = %s WHERE o.order_code = '%s'" % (
            module, table_index, result[0], i)
        cursor.execute(sql)
        try:
            db.commit()
            print("success: " + i + "-" + result[0])
        except:
            print("failed: " + i)
            db.rollback()
        db.close()
Ejemplo n.º 2
0
def query_order(order_list):
    for i in order_list:
        sql = "SELECT order_code, order_status, express_id, express_code,address,ship_date from sibu_directsale_order_{module}.doing_order_{table_index} WHERE order_code='{order_code}'"
        module = DbUtil.get_mod_16(DbUtil.get_module_by_order_code(i))
        table_index = DbUtil.get_mode_64(DbUtil.get_module_by_order_code(i))
        db_url = DbUtil.get_db_ip(module)
        db = pymysql.connect(host=db_url,
                             user="******",
                             passwd="Aa123456",
                             db="sibu_directsale",
                             charset="utf8mb4")
        sql = sql.format(module=module, table_index=table_index, order_code=i)
        cursor = db.cursor()
        cursor.execute(sql)
        print(cursor.fetchall())
        db.close()
Ejemplo n.º 3
0
def update_order_trade(list):
    for i in list:
        order_code = str(i[0])
        trade_id = str(i[1])

        module = DbUtil.get_mod_16(DbUtil.get_module_by_order_code(order_code))
        table_index = DbUtil.get_mode_64(
            DbUtil.get_module_by_order_code(order_code))
        db_url = DbUtil.get_db_ip(module)
        db = pymysql.connect(db_url, "root", "Aa123456", "sibu_directsale")
        cursor = db.cursor()
        sql = "UPDATE sibu_directsale_order_%s.doing_order_%s o SET o.payment_number = %s WHERE o.payment_number IS NULL AND o.order_code = '%s'" % (
            module, table_index, trade_id, order_code)
        result = cursor.execute(sql)
        if (result <= 0):
            print("订单流水号已经存在: %s" + order_code)
            continue
        try:
            db.commit()
            print("success:%s %s" % (order_code, trade_id))
        except:
            print("failed: " + order_code)
            db.rollback()
        db.close()