예제 #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()
예제 #2
0
def add_three_month(member_list):
    failed_count = 0
    success_count = 0
    sql = " UPDATE sibu_directsale_profit_{module}.member_deal d SET d.apply_date = DATE_ADD(d.apply_date,  INTERVAL 3 MONTH ) WHERE d.apply_month = {profit_month} " \
          "AND d.apply_money = {apply_money}*100 AND d.apply_member_id = '{member_id}' AND d.deal_status = 8"
    for i in member_list:
        apply_money = i[2]
        profit_month = i[1]
        member_id = i[0]
        module = DbUtil.get_mod_16(member_id)
        db = PyMysql.connect("10.47.32.108", "sibu_dbuser", "TY3WxTv9CIiOtefN",
                             "sibu_directsale")
        cursor = db.cursor()
        cursor.execute(
            sql.format(module=module,
                       profit_month=profit_month,
                       apply_money=apply_money,
                       member_id=member_id))
        try:
            db.commit()
            success_count += 1
            print("successCount: " + str(success_count))
        except:
            failed_count += 1
            print("failed: " + member_id + " count:" + str(failed_count))
            db.rollback()
        db.close()
예제 #3
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()
예제 #4
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()