- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含银行变动的表格,我正在从 csv 和 json 文件中导入这些变动,每个变动旁边都有一个金额和一个余额。
+------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| cuenta_banco_id | int(11) | NO | | NULL | |
| referencia | varchar(191) | NO | | NULL | |
| monto | decimal(10,2) | NO | | NULL | |
| saldo | decimal(10,2) | NO | | NULL | |
| type | int(11) | NO | | NULL | |
| user_id | int(11) | NO | | NULL | |
| fecha_movimiento | datetime | NO | | NULL | |
| created_at | timestamp | YES | | NULL | |
| updated_at | timestamp | YES | | NULL | |
+------------------+------------------+------+-----+---------+----------------+
10 rows in set (0.08 sec)
{
"Date": "22/04/2019",
"Operation": "MC",
"Reference": "15",
"Description": "TRANSF. VIA INTERNET ",
"Amount": "10000.00",
"Balance": "1869255.04"
}
文件正在完全导入数据库,问题是我需要在显示数据时正确排序
我需要按日期降序显示变动,但也需要正确显示余额。
我需要的例子:
这就是我获得运动的方式:
+------+-----------------+-------------+------------+-----------+------+---------+---------------------+---------------------+---------------------+
| id | cuenta_banco_id | referencia | monto | saldo | type | user_id | fecha_movimiento | created_at | updated_at |
+------+-----------------+-------------+------------+-----------+------+---------+---------------------+---------------------+---------------------+
| 3367 | 4 | 2297353555 | 10000.00 | 665445.90 | 0 | 1 | 2019-04-20 23:59:59 | 2019-04-20 18:15:33 | 2019-04-20 18:15:33 |
| 3366 | 4 | 2297322435 | 11000.00 | 655445.90 | 0 | 1 | 2019-04-20 23:59:59 | 2019-04-20 18:15:33 | 2019-04-20 18:15:33 |
| 3398 | 4 | 2297751229 | 11000.00 | 651695.90 | 0 | 1 | 2019-04-20 23:59:59 | 2019-04-20 18:15:34 | 2019-04-20 18:15:34 |
| 3362 | 4 | 2297311718 | 12000.00 | 651445.90 | 0 | 1 | 2019-04-20 23:59:59 | 2019-04-20 18:15:33 | 2019-04-20 18:15:33 |
| 3343 | 4 | 2296877327 | 10000.00 | 649845.90 | 0 | 1 | 2019-04-20 23:59:59 | 2019-04-20 18:15:33 | 2019-04-20 18:15:33 |
| 3365 | 4 | 2297317974 | -525000.00 | 644445.90 | 0 | 1 | 2019-04-20 23:59:59 | 2019-04-20 18:15:33 | 2019-04-20 18:15:33 |
| 3431 | 4 | 2298293430 | 13000.00 | 643195.90 | 0 | 1 | 2019-04-20 23:59:59 | 2019-04-20 18:15:35 | 2019-04-20 18:15:35 |
| 3397 | 4 | 2297748073 | 15900.00 | 640695.90 | 0 | 1 | 2019-04-20 23:59:59 | 2019-04-20 18:15:34 | 2019-04-20 18:15:34 |
| 3342 | 4 | 2296823905 | 30000.00 | 639845.90 | 0 | 1 | 2019-04-20 23:59:59 | 2019-04-20 18:15:33 | 2019-04-20 18:15:33 |
| 3361 | 4 | 64665863950 | 500000.00 | 639445.90 | 0 | 1 | 2019-04-20 23:59:59 | 2019-04-20 18:15:33 | 2019-04-20 18:15:33 |
+------+-----------------+-------------+------------+-----------+------+---------+---------------------+---------------------+---------------------+
10 rows in set (0.00 sec)
字段 cuenta_banco_id 标识拥有 movements 的银行,但不同银行的 movements 之间没有关系。
这是在 Laravel 5.7 和 MySQL 5.7.23 上,我使用的查询是:
$movimientos = Movimiento::query();
$movimientos->where('cuenta_banco_id', $request->banco);
$movimientos->whereBetween(DB::raw('date(fecha_movimiento)'), [$start->startOfDay()->format('Y-m-d H:i:s'), $end->endOfDay()->format('Y-m-d H:i:s')]);
$movimientos->with('recargas', 'banks', 'recargas.transactions', 'movimientos_detalles', 'recargas.transactions.siteuser');
$movimientos->orderBy('created_at', 'DESC');
$movimientos = $movimientos->paginate(50);
我怎样才能达到我的需要?
最佳答案
据我了解,您的交易纯粹是根据时间排序的(即,transaction_date DESC,然后是 created_time ASC)。并且由于你在银行ID上使用了where子句,我们这里只查看单个银行的交易(我不清楚它是否涵盖所有用户的交易。如果是这样,我们需要在申请前按用户划分订购方式)。假设“fecha_movimiento”捕获交易日期,“id”捕获交易顺序,您可以尝试这样的操作:
$movimientos->orderBy(DB::raw('date(fecha_movimiento)'), 'DESC')
->orderBy('id','ASC');
关于php - 按日期和余额排序银行移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55779086/
我正在创建一个在线学习平台,我们在其中使用 Moodle 输入和存储问题。我需要创建一个包装器,使用它我可以从我的应用程序访问 Moodle 的问题库。最好的方法是什么:插件还是 Web 服务?已经有
我有一个银行线程和 4 个 ATM 机 .txt 文件。(atm_0_input_file.txt - atm_4_input_file.txt)。 每个文件都是一个线程,一个bank也是一个线程。当
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 9 年前。 Improve this
当我使用“exchange_to (: CLP) .to_i”方法时,它在 OrdersController#create 中给我错误 Money::Bank::GoogleCurrencyFetch
您好,我对数据库的“用户”和从数据库访问其详细信息的企业“客户”感到困惑。 我正在构建一个网络,客户可以在其中登录并访问他们的银行余额、对账单、直接借记等(银行应用程序)。我的 SQL 数据库将有一个
我正在使用 Monzo 银行 API 开发一个金融应用程序,身份验证过程最终会从 Monzo api 接收 access_token:https://docs.monzo.com/#acquire-a
我正在设计银行 ATM 消息处理/路由框架,需要一些帮助来完成技术和架构。交易来自多个合作银行的 ATM,比如目前我们为 5 到 6 家银行提供服务,每家银行不超过 10 台 ATMS。 消息通过 t
我是第一次使用 Stripe,对它们提供的不同 API 有点困惑。有一个 Payment Method API,它是推荐用于处理客户付款方式的 API,但目前它只支持信用卡,如果我理解正确的话....
我是一名优秀的程序员,十分优秀!