97 lines
2.3 KiB
PHP
97 lines
2.3 KiB
PHP
<?php
|
|
namespace app\common\model;
|
|
|
|
use app\common\model\Base;
|
|
use think\Model;
|
|
|
|
class OrderNotify extends Base
|
|
{
|
|
// 设置当前模型对应的完整数据表名称
|
|
protected $table = 'order_notify';
|
|
|
|
// 设置主键
|
|
protected $pk = 'id';
|
|
|
|
// 自动写入时间戳
|
|
protected $autoWriteTimestamp = true;
|
|
|
|
/**
|
|
* 获取列表
|
|
*/
|
|
public static function getList($where = [], $field = '*', $order = '', $pageSize = "15")
|
|
{
|
|
$list = self::where($where)
|
|
->field($field)
|
|
->order($order)
|
|
->paginate(['list_rows' => $pageSize, 'query' => request()->param()]);
|
|
$page = $list->render();
|
|
$data['list'] = $list->toArray()['data'];
|
|
$data['count'] = $list->total();
|
|
$data['last_page'] = $list->toArray()['last_page'];
|
|
$data['page'] = $page;
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* 获取列表 不分页
|
|
*/
|
|
public static function getAllList($where = [], $field = '*', $order = '', $limit = '0')
|
|
{
|
|
$data = self::where($where)
|
|
->field($field)
|
|
->order($order)
|
|
->limit($limit)
|
|
->select();
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* 获取单条数据
|
|
*/
|
|
public static function getInfo($where = [], $field = '*')
|
|
{
|
|
$data = self::where($where)
|
|
->field($field)
|
|
->find();
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* 根据订单号获取回调信息
|
|
*/
|
|
public static function getByOrderNo($orderNo, $field = '*')
|
|
{
|
|
return self::where('order_no', $orderNo)
|
|
->field($field)
|
|
->find();
|
|
}
|
|
|
|
/**
|
|
* 更新回调状态
|
|
*/
|
|
public static function updateStatus($id, $status, $remark = null)
|
|
{
|
|
$data = [
|
|
'status' => $status,
|
|
'last_notify_time' => date('Y-m-d H:i:s')
|
|
];
|
|
|
|
if (!is_null($remark)) {
|
|
$data['remark'] = $remark;
|
|
}
|
|
|
|
return self::update($data, ['id' => $id]);
|
|
}
|
|
|
|
/**
|
|
* 增加重试次数
|
|
*/
|
|
public static function increaseRetryCount($id)
|
|
{
|
|
return self::where('id', $id)
|
|
->inc('retry_count')
|
|
->update([
|
|
'last_notify_time' => date('Y-m-d H:i:s')
|
|
]);
|
|
}
|
|
}
|