def listByPage(conditionJson, likeConditionjson=None, page_no=1, page_size=15, headers=None, **kwargs): ''' 分页查询账户信息 ''' try: conditionJson = json.loads(conditionJson) likeConditionjson = json.loads(likeConditionjson) accountDao = AccountDao() result = accountDao.getAccountByPage( accountDao.getQueryByCondition(conditionJson, likeConditionjson), page_no, page_size) dataResult = [] if result: for account in result: dataResult.append(getJsonFromObj(account, ACCOUNT_OBJECT_KEY)) return outSuccess( "accountList", pagePackage("accounts", dataResult, page_no=result.no, page_size=result.page_size, total=result.total)) except Exception as e: LOG.error(str(e)) LOG.error(traceback.format_exc()) return outError("取得账户列表失败!")
def getOrderRechargeList(account_id=None, payment_type=None, started_at=None, ended_at=None,page_no=1,page_size=15): try: orderDao = OrderDao() result,count = orderDao.getOrderRechargeList(account_id, payment_type, started_at, ended_at,page_no,page_size) return outSuccess("billList", pagePackage("bills", result, page_no=page_no, page_size=page_size, total=count)) except Exception as e: LOG.error(str(e)) LOG.error(traceback.format_exc()) return outError("取得账单列表失败!")
def subAccountConsumptionList(account_id, started_at, ended_at, condition, page_no=1, page_size=15): '''子账户消费列表''' try: account = Account() account.account_id = account_id accountDao = AccountDao(account) accountDao.detail() rows, count = accountDao.subAccountList(accountDao.account.user_id, condition, page_no, page_size) result = [] if datetime2Str(started_at) == change2UTC( datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m') + '-01', format='%Y-%m-%d') and datetime2Str( datetime2Str(ended_at, outformat='%Y-%m-%d %H'), informat='%Y-%m-%d %H') == change2UTC( datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H'), format='%Y-%m-%d %H'): if rows: accountDao = AccountDao() for row in rows: account = Account() account.account_id = row['account_id'] accountDao.account = account accountDao.detail() row['amount_total'] = accountDao.account.current_month_amount row['standard_amount_total'] = accountDao.account.current_month_standard_amount result.append(row) else: if rows: consumptionDao = ConsumptionDao() for row in rows: total = consumptionDao.getAmountSummary( row['account_id'], started_at, ended_at) result.append(dict(row, **total)) return outSuccess( 'subAccountConsumptionList', pagePackage("accounts", result, page_no=page_no, page_size=page_size, total=count)) except Exception as e: LOG.error(str(e)) LOG.error(traceback.format_exc()) return outError("取得子账户消费列表失败!")
def listByPage(conditionJson, page_no=1, page_size=15, headers=None, **kwargs): try: conditionJson=json.loads(conditionJson) invoiceDao = InvoiceDao() result = invoiceDao.getInvoiceByPage(conditionJson, page_no, page_size) dataResult = [] if result: for invoice in result: dataResult.append(getJsonFromObj(invoice)) return outSuccess("invoiceList", pagePackage("invoices", dataResult, page_no=result.no, page_size=result.page_size, total=result.total)) except Exception as e: LOG.error(str(e)) LOG.error(traceback.format_exc()) return outError("取得发票列表失败!")
def ProjectAdminsubAccountList(account_id, condition=None): try: account = Account() account.account_id = account_id accountDao = AccountDao(account) accountDao.detail() result, count = accountDao.ProjectAdminsubAccountList( accountDao.account.user_id, condition) print result return outSuccess('subAccountList', pagePackage('accounts', result, total=count)) except Exception as e: LOG.error(str(e)) LOG.error(traceback.format_exc()) return outError("取得子账户列表失败!")
def subAccountList(account_id, condition=None, page_no=1, page_size=15): try: account = Account() account.account_id = account_id accountDao = AccountDao(account) accountDao.detail() result, count = accountDao.subAccountList(accountDao.account.user_id, condition, page_no, page_size) return outSuccess( "subAccountList", pagePackage("accounts", result, page_no=page_no, page_size=page_size, total=count)) except Exception as e: LOG.error(str(e)) LOG.error(traceback.format_exc()) return outError("取得子账户列表失败!")
def list(account_id, started_at=None, ended_at=None, page_no=1, page_size=15, isBillItems=False, bill_type=None): try: billDao = BillDao() result = billDao.list(account_id, started_at, ended_at, page_no, page_size, isBillItems, bill_type=bill_type) dataresult = [] if result: if isBillItems: dataresult = [ getJsonFromObj(bill, BILL_OBJECT_KEY_SIMPLE) for bill in result ] else: dataresult = [ getJsonFromObj(bill, BILL_OBJECT_KEY) for bill in result ] return outSuccess( "billList", pagePackage("bills", dataresult, page_no=result.no, page_size=result.page_size, total=result.total)) except Exception as e: LOG.error(str(e)) LOG.error(traceback.format_exc()) return outError("取得账单列表失败!")