add contract for product and refund parse

This commit is contained in:
2026-03-05 10:07:51 +08:00
parent d93fdee203
commit 4c49c2b71c
9 changed files with 122 additions and 38 deletions
-22
View File
@@ -5,7 +5,6 @@ declare(strict_types=1);
namespace App\Platform;
use App\Entity\Parse\EntityParseFactory;
use App\Entity\Parse\EntityParseInterface;
use App\Utils\Log;
use Hyperf\Amqp\Annotation\Consumer;
use Hyperf\Amqp\Builder\QueueBuilder;
@@ -15,7 +14,6 @@ use Hyperf\Amqp\Producer;
use PhpAmqpLib\Message\AMQPMessage;
use Hyperf\DbConnection\Db;
use App\Model\RefundItem;
use Exception;
use Hyperf\Context\ApplicationContext;
use Throwable;
@@ -71,8 +69,6 @@ class RefundConsumer extends ConsumerMessage
try {
$parse = EntityParseFactory::createFromMessage($message);
$this->parseValidate($parse);
$meta = $data['meta'] ?? [];
$metadata = [
'company_id' => $meta['company_id'] ?? null,
@@ -299,22 +295,4 @@ class RefundConsumer extends ConsumerMessage
dump("Refund items processing completed");
}
protected function parseValidate(EntityParseInterface $parse): void
{
if (!method_exists($parse, 'hasParentRefund')) {
throw new Exception('hasParentRefund method must be implemented in ' . $parse::class);
}
if (!method_exists($parse, 'formatRefundItemsFromRaw')) {
throw new Exception('formatRefundItemsFromRaw method must be implemented in ' . $parse::class);
}
if (!method_exists($parse, 'getRefundStatusId')) {
throw new Exception('getRefundStatusId method must be implemented in ' . $parse::class);
}
if (!method_exists($parse, 'getRefundTypeId')) {
throw new Exception('getRefundTypeId method must be implemented in ' . $parse::class);
}
}
}