feat : spu
This commit is contained in:
@@ -10,7 +10,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Amqp\Refund;
|
||||
|
||||
use App\Constants\Common\OrderCode;
|
||||
use App\Event\RefundGoodOrderFinishEvent;
|
||||
use App\Lib\Log;
|
||||
use App\Model\Order;
|
||||
use App\Model\PayOrder;
|
||||
use App\Model\RefundOrder;
|
||||
@@ -19,8 +20,10 @@ use App\Service\ServiceTrait\Api\CouponTrait;
|
||||
use App\Service\ServiceTrait\Api\OrderTrait;
|
||||
use App\Service\ServiceTrait\Api\RefundOrderTrait;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
class RefundGoodOrderFinishService
|
||||
{
|
||||
@@ -44,6 +47,11 @@ class RefundGoodOrderFinishService
|
||||
*/
|
||||
public int $orderType;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public array $callbackData;
|
||||
|
||||
/**
|
||||
* @var Order
|
||||
*/
|
||||
@@ -59,23 +67,47 @@ class RefundGoodOrderFinishService
|
||||
*/
|
||||
protected RefundOrder $refundInfo;
|
||||
|
||||
/**
|
||||
* @var EventDispatcherInterface
|
||||
*/
|
||||
#[Inject]
|
||||
private EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
/**
|
||||
* @var Log
|
||||
*/
|
||||
#[Inject]
|
||||
protected Log $log;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected bool $rollBackStockFlag;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->checkRefundOrder();
|
||||
|
||||
$this->rollBackStockFlag = $this->orderInfo->cycle_id == $this->initTodayCycleId();
|
||||
|
||||
Db::transaction(function (){
|
||||
$this->manageRefundOrder();
|
||||
|
||||
$this->manageOrderByRefund();
|
||||
|
||||
$this->manageSubCateringLog();
|
||||
|
||||
if ($this->orderInfo->coupin_id > 0) $this->rollbackCoupon(OrderCode::ORDER_TYPE_GOOD,$this->orderInfo);
|
||||
});
|
||||
|
||||
// $this->sendStockMq($this->orderInfo->id,$this->orderInfo->status);
|
||||
if ($this->rollBackStockFlag) {
|
||||
$this->sendStockMq($this->orderInfo->id,$this->orderInfo->status);
|
||||
}
|
||||
|
||||
$this->eventDispatcher->dispatch(new RefundGoodOrderFinishEvent($this->orderInfo->id, $this->payInfo->id, $this->refundInfo->id));
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user