Day22 订单金流 -- log纪录

没错今天又是金流payment的额外扩充,
要讲的是log纪录,一样先上结构

Schema::create('payment', function (Blueprint $table) {
    $table->string('id', 30)->comment('同订单id');
    $table->string('payment_id', 30)->comment('金流单id');
    $table->string('type', 20)->comment('付款类型'); //credit, atm
    $table->string('status', 30)->default('unpaid')->comment('金流状态');
    $table->dateTime('expired_at')->nullable()->comment('付款截止时间');
    $table->dateTime('paid_at')->nullable()->comment('付款时间');
    $table->text('info')->nullable(); // 付款资讯物件(ATM帐号/超商代码/超商条码)
    $table->float('amount')->default(0); // 金额
    $table->float('fee')->default(0); // 手续费
    $table->primary(['id']);
});

//新增金流log table
Schema::create('payment_log', function (Blueprint $table) {
    $table->string('id', 30);
    $table->string('order_id', 30);
    $table->string('payment_id', 100)->nullable()->comment('金流单id');
    $table->string('service_order_id', 100)->nullable()->comment('第三方金流单id');
    $table->string('status', 30)->comment('金流状态');
    $table->text('response')->nullable()->comment('金流方回传内容');
    $table->timestamps();
    $table->primary(['id']);
    $table->index(['payment_id']);
});

这边我们新增了table payment_log,因为金流的沟通可能会有很多次来往,
因此需要纪录下每次接收到的资讯,不管在查询还是bebug都很方便,
这边注意一下除了本来的payment_id之外,还有特别纪录order_id,
主要是因为payment_id为了要符合重复付款的部份可能会换,
所以要有order_id方便我们filter出该笔订单的全部金流纪录,
其他的status、response就是该资料对应的状态以及回传内容,
至於第三方金流单号(永丰金是TSNo)service_order_id算是比较非必要,
属於个人喜好的栏位,各位也可自行新增删除觉得有需要或者没必要的栏位。

有了金流、金流纪录我们订单交易的部份快到尾声了,
剩下还有一些状态卡点补充,以及最後的常用案例,
good bye.


<<:  DVWA练习-Weak Session IDs

>>:  Day 13 - UML x Interface — Transition

追求JS小姊姊系列 Day2 -- 谁说难搞的女生没朋友?

前情提要 先帮大家回味一下,第一天我说了些哪些内容: 之前跟她装熟很失败,现在决心要打掉重练 啊,可...

Day 05 - 回顾铁人赛文章的描述性统计分析

在继续开始谈各个面向的题材之前,  还是不免俗地回顾一下自己的数位足迹, 包括了前三年的铁人赛成果...

Day28 - 储存帐密及自动登入

今天来做储存帐密和自动登入的功能。 提醒:今天的内容缺少了加密储存密码,是极度危险的功能,这部份预计...

Day21-"排序、搜寻介绍"

剩最後10篇了,一起加油! 我们通常都会一次存入多笔资料,在这时候搜寻以及排序就变得相当重要,若是做...

【C#】Abstract Class vs Interface

我们今天来看到抽象类别跟介面的差异性吧~ 学习目标: Abstract Class and Inte...