Esempio n. 1
0
def delete(c_id, ):
    try:
        sql = "DELETE FROM `tms_initialize` WHERE c_id={};".format(c_id)
        sql_('localhost', sql)
        return responseJSON_1('删除成功')
    except TypeError as err:
        return responseJSON_0('删除成功', err)
Esempio n. 2
0
def getInvoiceCompanyType(c_id):
    type = '''
		SELECT ws_status,ws_two_status FROM tms_wl_wallet WHERE `c_id` = '{}';
	'''.format(c_id)
    type = sql_('tms_test', type)
    if len(type) < 1:
        return responseJSON_1(0)
    ws_status = type[0]['ws_status']
    ws_two_status = type[0]['ws_two_status']
    if ws_status == 2 and (ws_two_status == 0 or ws_two_status):
        return responseJSON_1(1)
    elif ws_two_status == 2 and (ws_status == 0 or ws_status == 4):
        return responseJSON_1(2)
    else:
        print_err('请使用网商1.0或网商2.0物流公司' + 'c_id:{}'.format(c_id))
        return responseJSON_0(0)
Esempio n. 3
0
def delete(mobile, ):
    try:
        sql = "DELETE FROM `driver_initialize` WHERE mobile={};".format(mobile)
        sql_('localhost', sql)
        return responseJSON_1('删除成功:', mobile)
    except TypeError as err:
        return responseJSON_0(
            '删除失败',
            err,
        )
Esempio n. 4
0
def WLinitialize(c_id, execute_time):
	invoiceCompanyType = getInvoiceCompanyType(c_id)
	ws2_balance = getWsBalance(c_id,invoiceCompanyType["msg"])
	invoiceCompanyId = gerInvoiceCompanyId(c_id)
	invoice_company_balance = getWsBalance(invoiceCompanyId,invoiceCompanyType["msg"])
	ws_two_balance = getWlBalance(c_id)
	upaidData = getUnpaidData(c_id)
	insert_ = insert(c_id, ws2_balance, ws_two_balance, upaidData["count_"], invoice_company_balance, execute_time)
	if insert_['code'] == 0:
		return insert_
	return responseJSON_1('TMS初始化成功!',insert_)
Esempio n. 5
0
def checking(c_id_list, mobile_list):
	execute_time = int(time.time())
	for i in mobile_list:
		mobile_delete(i)
	for i in c_id_list:
		tms_delete(i)
	for c_id in c_id_list:
		WLinitialize(c_id, execute_time)
	for mobile in mobile_list:
		is_true = EntrustInitialize(mobile, execute_time)
		if is_true['code'] == 0:
			return is_true
	return responseJSON_1('初始化成功!','初始化代码:{}'.format(execute_time))
Esempio n. 6
0
def EntrustInitialize(mobile, execute_time):
	driverWallet = getZybdbWallet(mobile)
	if driverWallet['code'] == 0:
		return driverWallet
	user_id = driverWallet['table_s']['user_id']
	sum_balance = driverWallet['table_s']['balance'] + driverWallet['table_s']['out']
	balance = driverWallet['table_s']['balance']
	freeze = driverWallet['table_s']['freeze']
	extract = driverWallet['table_s']['out']
	DriverInitialize = setDriverInitialize(user_id, mobile, balance, freeze, extract, sum_balance, execute_time)
	if DriverInitialize['code'] == 0:
		return DriverInitialize
	return responseJSON_1('初始化成功')
Esempio n. 7
0
def insert(c_id, ws_wallet, wl_wallet, pay_order_count, invoice_wallet,
           execute_time):
    try:
        sql = """
			INSERT INTO tms_initialize ( c_id, ws_wallet, wl_wallet, pay_order_count,invoice_wallet,time ) VALUES ( %s, %s, %s, %s ,%s, %s);
			""" % (c_id, str(ws_wallet), str(wl_wallet), int(pay_order_count),
          str(invoice_wallet), str(execute_time))
        data = sql_('localhost', sql)
        if len(data) == 0:
            return responseJSON_1('数据更新成功!')
        else:
            return responseJSON_0('数据更新失败!', sql)
    except TypeError as err:
        return responseJSON_0('数据更新异常!', err)
Esempio n. 8
0
def setDriverInitialize(user_id, mobile, balance, freeze, out, sum_balance,
                        execute_time):
    try:
        sql = """
			INSERT INTO driver_initialize (user_id,mobile,balance,freeze,`out`,sum_balance,time) VALUES (%d,%s,%e,%e,%e,%e,%s)
			""" % (user_id, mobile, float(balance), float(freeze), float(out),
          float(sum_balance), str(execute_time))
        data = sql_('localhost', sql)
        if len(data) == 0:
            return responseJSON_1('更新成功!')
        else:
            return responseJSON_0('更新失败!')
    except TypeError as err:
        return responseJSON_0('更新失败!', err)
Esempio n. 9
0
def checking(time):
    count_c_id = '''
		SELECT numbers count_c_id from (SELECT COUNT(c_id) as numbers FROM tms_initialize 
		WHERE time = '{}' GROUP BY c_id) a GROUP BY numbers;
	'''.format(time)
    count_mobile = '''
			SELECT numbers count_c_id from (SELECT COUNT(mobile) as numbers FROM driver_initialize 
			WHERE time = '{}' GROUP BY mobile) a GROUP BY numbers;
		'''.format(time)
    c_id = '''
	SELECT c_id FROM tms_initialize WHERE time = '{}' GROUP BY c_id;
	'''.format(time)
    mobile = '''
		SELECT mobile FROM driver_initialize WHERE time = '{}' GROUP BY mobile;
		'''.format(time)
    count_c_id = sql_('localhost', count_c_id)
    c_id = sql_('localhost', c_id)
    count_mobile = sql_('localhost', count_mobile)
    mobile = sql_('localhost', mobile)
    if len(count_c_id) == 0 or len(count_mobile) == 0:
        return responseJSON_0('初始化ID无效!', '初始化ID:{}'.format(time))
    elif len(count_c_id) == len(count_mobile) == 1:
        payTotalWallet = 0
        serviceFeeIncometTotal = 0
        driverAddWallerTotal = 0
        if count_c_id[0]['count_c_id'] == 1:
            '''
			未对账
			'''
            for i in c_id:
                initialize = WLinitialize(i['c_id'], time)
                if initialize['code'] == 0:
                    return initialize
                print_warn_(initialize)
            for i in mobile:
                entrustInitialize = EntrustInitialize(i['mobile'], time)
                if entrustInitialize['code'] == 0:
                    return initialize

            for i in c_id:
                payWallet = getPayWallet(i['c_id'])
                payTotalWallet += float(payWallet)
                print_suc(str(i['c_id']) + '物流公司支付:' + str(payWallet) + '元')

                serviceFeeIncomet = getServiceFeeIncomet(i['c_id'])
                print_suc(
                    str(i['c_id']) + '物流公司分公司收入服务费:' + str(serviceFeeIncomet) +
                    '元')
                serviceFeeIncometTotal += float(serviceFeeIncomet)

            for i in mobile:
                driverAddWaller = grtDriverAddWaller(i['mobile'])
                print_suc(
                    str(i['mobile']) + '司机收入运费:' + str(driverAddWaller) + '元')
                driverAddWallerTotal += float(driverAddWaller)
            print_suc('\n物流公司总支出运费:{}'.format(payTotalWallet))
            print_suc('分公司总收入服务费:{}'.format(serviceFeeIncometTotal))
            print_suc('司机总收入运费:{}'.format(driverAddWallerTotal))
            if (payTotalWallet -
                    serviceFeeIncometTotal) == driverAddWallerTotal:
                return responseJSON_1(
                    '\n---------------对账成功------------------!\n')
            else:
                return responseJSON_0(
                    '\n---------------对账失败!\n---------------')
        elif count_c_id[0]['count_c_id'] == 2:
            '''
			已对账
			'''

            for i in c_id:
                payWallet = getPayWallet(i['c_id'])
                print_suc(str(i['c_id']) + '物流公司支付:' + str(payWallet) + '元')
                payTotalWallet += float(payWallet)

                serviceFeeIncomet = getServiceFeeIncomet(i['c_id'])
                print_suc(
                    str(i['c_id']) + '物流公司分公司收入服务费:' + str(serviceFeeIncomet) +
                    '元')
                serviceFeeIncometTotal += float(serviceFeeIncomet)

            for i in mobile:
                driverAddWaller = grtDriverAddWaller(i['mobile'])
                print_suc(
                    str(i['mobile']) + '司机收入运费:' + str(driverAddWaller) + '元')
                driverAddWallerTotal += float(driverAddWaller)
            print_suc('\n物流公司总支出运费:{}'.format(payTotalWallet))
            print_suc('分公司总收入服务费:{}'.format(serviceFeeIncometTotal))
            print_suc('司机总收入运费:{}'.format(driverAddWallerTotal))
        else:
            return responseJSON_0('对账数据异常', '对账ID:{}'.format(time))
    else:
        return responseJSON_0('初始化数据异常', '初始化ID:{}'.format(time))