feat : spu
This commit is contained in:
@@ -213,13 +213,15 @@ abstract class BaseRefundOrderService
|
||||
$this->refundInfo = new RefundOrder();
|
||||
|
||||
$this->refundInfo->user_id = $this->orderInfo->user_id;
|
||||
$this->refundInfo->order_type = $this->type;
|
||||
$this->refundInfo->order_type = OrderCode::ORDER_TYPE_GOOD;
|
||||
$this->refundInfo->order_id = $this->orderId;
|
||||
$this->refundInfo->pay_id = $this->payInfo->id;
|
||||
$this->refundInfo->type = $this->type;
|
||||
if ($this->type == RefundCode::PARTIAL_GOOD_REFUND) $this->refundInfo->good_ids = json_encode($this->orderGoodIds);
|
||||
$this->refundInfo->refund_status = RefundCode::WAIT_REFUND;
|
||||
$this->refundInfo->refund_money = $this->refundAmount;
|
||||
$this->refundInfo->refund_type = $this->payInfo->recharge_type;
|
||||
$this->refundInfo->refund_order_sno = $this->generateRefundOrderNo($this->type, $this->orderInfo->user_id);
|
||||
$this->refundInfo->refund_order_sno = $this->generateRefundOrderNo(OrderCode::ORDER_TYPE_GOOD, $this->orderInfo->user_id);
|
||||
$this->refundInfo->reason = $this->reason;
|
||||
|
||||
if (!$this->refundInfo->save()) throw new Exception('退款订单创建失败');
|
||||
|
||||
@@ -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