add contract for product and refund parse
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Platform;
|
||||
|
||||
use App\Entity\Parse\EntityParse;
|
||||
|
||||
/**
|
||||
* 退款解析器抽象基类
|
||||
*
|
||||
* 继承 EntityParse 的通用能力,并实现 RefundContract 契约
|
||||
* 提供退款解析的通用方法和辅助函数
|
||||
*/
|
||||
abstract class AbstractRefundParse extends EntityParse implements RefundContract
|
||||
{
|
||||
/**
|
||||
* 获取退款状态 ID(抽象方法,由子类实现)
|
||||
*/
|
||||
abstract public function getRefundStatusId(string $platform_status): int;
|
||||
|
||||
/**
|
||||
* 获取退款类型 ID(抽象方法,由子类实现)
|
||||
*/
|
||||
abstract public function getRefundTypeId(array $record): int;
|
||||
|
||||
/**
|
||||
* 是否有父退款(抽象方法,由子类实现)
|
||||
*/
|
||||
abstract public function hasParentRefund(): bool;
|
||||
|
||||
/**
|
||||
* 从原始数据格式化退款子项(抽象方法,由子类实现)
|
||||
*/
|
||||
abstract public function formatRefundItemsFromRaw(array $raw_data, ?array $platform_refund_id_to_local_refund_id_map): array;
|
||||
|
||||
/**
|
||||
* 通用辅助方法:格式化货币金额
|
||||
*
|
||||
* @param float|int|string|null $amount 金额
|
||||
* @param int $decimals 小数位数,默认 2 位
|
||||
* @return float 格式化后的金额
|
||||
*/
|
||||
protected function formatAmount(float|int|string|null $amount, int $decimals = 2): float
|
||||
{
|
||||
return round((float)($amount ?? 0), $decimals);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user