payment1
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
namespace app\model;
|
||||
|
||||
/**
|
||||
* 支付订单模型
|
||||
*/
|
||||
class PaymentOrder extends Base
|
||||
{
|
||||
/**
|
||||
* 数据表名
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'payment_order';
|
||||
|
||||
/**
|
||||
* 获取状态列表
|
||||
* @return array
|
||||
*/
|
||||
public static function getStatusList(): array
|
||||
{
|
||||
return \app\enum\Payment\Status::toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型列表
|
||||
* @return array
|
||||
*/
|
||||
public static function getTypeList(): array
|
||||
{
|
||||
return \app\enum\Payment\Type::toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付类型列表
|
||||
* @return array
|
||||
*/
|
||||
public static function getPayTypeList(): array
|
||||
{
|
||||
return \app\enum\Payment\Method::toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单号查询
|
||||
* @param string $orderNo
|
||||
* @return array|null
|
||||
*/
|
||||
public static function findByOrderNo(string $orderNo): ?array
|
||||
{
|
||||
return self::where('order_no', $orderNo)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新订单状态
|
||||
* @param string $orderNo
|
||||
* @param string $status
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public static function updateStatus(string $orderNo, string $status, array $data = []): bool
|
||||
{
|
||||
$updateData = array_merge([
|
||||
'status' => $status,
|
||||
'updated_at' => time(),
|
||||
], $data);
|
||||
|
||||
return self::where('order_no', $orderNo)->update($updateData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态文本
|
||||
* @param string $status
|
||||
* @return string
|
||||
*/
|
||||
public static function getStatusText(string $status): string
|
||||
{
|
||||
$list = self::getStatusList();
|
||||
return $list[$status] ?? $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型文本
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
public static function getTypeText(string $type): string
|
||||
{
|
||||
$list = self::getTypeList();
|
||||
return $list[$type] ?? $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取支付类型文本
|
||||
* @param string $payType
|
||||
* @return string
|
||||
*/
|
||||
public static function getPayTypeText(string $payType): string
|
||||
{
|
||||
$list = self::getPayTypeList();
|
||||
return $list[$payType] ?? $payType;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user