86 lines
1.7 KiB
PHP
86 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* This service file is part of item.
|
|
*
|
|
* @author ctexthuang
|
|
* @contact ctexthuang@qq.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Service\Amqp\Pay;
|
|
|
|
use App\Constants\Common\RefundCode;
|
|
use App\Model\Order;
|
|
use App\Model\PayOrder;
|
|
use App\Service\ServiceTrait\Api\CateringTrait;
|
|
use App\Service\ServiceTrait\Api\GoodOrderTrait;
|
|
use App\Service\ServiceTrait\Api\PayFinishTrait;
|
|
use App\Service\ServiceTrait\Common\OrderChangeStatusTrait;
|
|
use Hyperf\DbConnection\Db;
|
|
use Psr\Container\ContainerExceptionInterface;
|
|
use Psr\Container\NotFoundExceptionInterface;
|
|
|
|
class PayGoodOrderFinishService
|
|
{
|
|
use GoodOrderTrait;
|
|
use PayFinishTrait;
|
|
use CateringTrait;
|
|
use OrderChangeStatusTrait;
|
|
|
|
/**
|
|
* @var string
|
|
*/
|
|
public string $orderNo;
|
|
|
|
/**
|
|
* @var int
|
|
*/
|
|
public int $payType;
|
|
|
|
/**
|
|
* @var int
|
|
*/
|
|
public int $orderType;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
public array $callbackData;
|
|
|
|
/**
|
|
* @var Order
|
|
*/
|
|
protected Order $orderInfo;
|
|
|
|
/**
|
|
* @var PayOrder
|
|
*/
|
|
protected PayOrder $payInfo;
|
|
|
|
/**
|
|
* @var bool 是否加入配餐数据
|
|
*/
|
|
protected bool $isCatering = true;
|
|
|
|
/**
|
|
* @return void
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
$this->checkCallBackOrder();
|
|
|
|
Db::transaction(function (){
|
|
$this->manageOrder();
|
|
|
|
$this->manageWxOrder();
|
|
//
|
|
$this->isCatering = $this->manageAddCateringLog();
|
|
});
|
|
|
|
//已经截单 自动退款
|
|
if (!$this->isCatering) $this->joinRefundQueue($this->orderInfo->id,RefundCode::FULL_GOOD_REFUND,'已截单,系统自动退款');
|
|
}
|
|
} |