You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
1.9 KiB
81 lines
1.9 KiB
<?php
|
|
|
|
namespace app\money\model;
|
|
|
|
use app\base\model\user\UserInfo;
|
|
use think\model\concern\SoftDelete;
|
|
|
|
class MoneyOrder extends Base
|
|
{
|
|
use SoftDelete;
|
|
|
|
protected $type = [
|
|
'pay_time' => 'timestamp',
|
|
'card_snapshot' => 'serialize'
|
|
];
|
|
|
|
/**
|
|
* 获取状态名称
|
|
* @date 2021-03-01
|
|
*/
|
|
public function getStatusTextAttr($value, $data)
|
|
{
|
|
$status_text = [
|
|
1 => '待支付',
|
|
2 => '待发货',
|
|
3 => '待收货',
|
|
4 => '待评价',
|
|
5 => '已完成',
|
|
6 => '退款中',
|
|
7 => '退款成功',
|
|
8 => '已取消',
|
|
];
|
|
return $status_text[$data['status']];
|
|
}
|
|
|
|
/**
|
|
* 获取付款方式名称
|
|
* @date 2021-03-01
|
|
*/
|
|
public function getPayTypeTextAttr($value, $data)
|
|
{
|
|
$pay_type_text = [
|
|
1 => '微信支付',
|
|
2 => '支付宝支付'
|
|
];
|
|
return $pay_type_text[$data['pay_type']];
|
|
}
|
|
|
|
/**
|
|
* 查找全部数据--带分页
|
|
* @param array $where 查询条件
|
|
* @param string $field 查询字段
|
|
* @param string $order 排序方式
|
|
* @param int $page 当前页数
|
|
* @date 2022-12-16
|
|
*/
|
|
public function listOrderWithPage($where, $page, $field = '*', $order = '')
|
|
{
|
|
if (empty($order)) {
|
|
$order = 'id desc';
|
|
}
|
|
|
|
$data_list = $this->field($field)->where($where)->order($order)
|
|
->paginate(['list_rows' => 50, 'page' => $page], false)->each(function ($item){
|
|
$item['show_create_time'] = date("Y.m.d H:i", $item->getData('create_time'));
|
|
unset($item['create_time']);
|
|
});
|
|
|
|
return $data_list;
|
|
}
|
|
|
|
/**
|
|
* 下单人信息
|
|
*/
|
|
public function userInfo()
|
|
{
|
|
return $this->hasOne(UserInfo::class,'user_id','user_id')->bind(['nick_name']);
|
|
}
|
|
|
|
|
|
} |