feat : spu
This commit is contained in:
@@ -9,12 +9,15 @@ use App\Model\OrderMealCateringLog;
|
||||
use App\Model\OrderOptionCateringLog;
|
||||
use App\Model\Sku;
|
||||
use App\Model\Spu;
|
||||
use App\Service\ServiceTrait\Common\CycleTrait;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
trait CateringTrait
|
||||
{
|
||||
use CycleTrait;
|
||||
|
||||
/**
|
||||
* @var OrderOptionCateringLog
|
||||
*/
|
||||
@@ -54,6 +57,8 @@ trait CateringTrait
|
||||
*/
|
||||
private function manageSubCateringLog(): void
|
||||
{
|
||||
if (!$this->rollBackStockFlag) return;
|
||||
|
||||
match ($this->orderInfo->type) {
|
||||
OrderCode::ORDER_TYPE_MEAL => $this->manageSubMealCateringLog(),
|
||||
OrderCode::ORDER_TYPE_OPTIONAL => $this->manageSubOptionCateringLog(),
|
||||
|
||||
@@ -6,7 +6,9 @@ use App\Constants\Common\OrderCode;
|
||||
use App\Constants\Common\PayCode;
|
||||
use App\Constants\Common\RefundCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\OrderGood;
|
||||
use Exception;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
@@ -17,9 +19,9 @@ trait RefundOrderTrait
|
||||
*/
|
||||
protected function checkRefundOrder(): void
|
||||
{
|
||||
$this->refundInfo = $this->refundOrderModel->getInfoByOrderSnoAndType($this->orderNo,self::PayType);
|
||||
$this->refundInfo = $this->refundOrderModel->getInfoByOrderSnoAndType($this->orderSno,$this->payType);
|
||||
$this->orderInfo = $this->orderModel->getInfoById($this->refundInfo->order_id);
|
||||
$this->payInfo = $this->payOrderModel->getInfoByOrderIdAndTypeAndRType($this->orderInfo->id,self::OrderType,self::PayType);
|
||||
$this->payInfo = $this->payOrderModel->getInfoByOrderIdAndTypeAndRType($this->orderInfo->id,$this->orderType,$this->payType);
|
||||
|
||||
if (empty($this->orderInfo) || empty($this->payInfo) || empty($this->refundInfo)) throw new ErrException('订单不存在');
|
||||
|
||||
@@ -48,6 +50,12 @@ trait RefundOrderTrait
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @var OrderGood
|
||||
*/
|
||||
#[Inject]
|
||||
protected OrderGood $orderGoodModel;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
@@ -62,13 +70,17 @@ trait RefundOrderTrait
|
||||
|
||||
if ($isRefundMoney == $this->payInfo->pay_money) {
|
||||
$this->orderInfo->status = OrderCode::FINISH_REFUND;
|
||||
$this->orderInfo->is_refund_all = 1;//todo 感觉可以删除这个值
|
||||
} else {
|
||||
$this->orderInfo->status = OrderCode::UNCOMPLETED_REFUND;
|
||||
}
|
||||
|
||||
if (!$this->orderInfo->save()) throw new Exception('更新退款订单失败');
|
||||
|
||||
match ($this->refundInfo->type) {
|
||||
RefundCode::FULL_GOOD_REFUND => $this->orderGoodModel->where('order_id',$this->refundInfo->order_id)->update(['refund_status' => OrderCode::FINISH_REFUND]),
|
||||
RefundCode::PARTIAL_GOOD_REFUND => $this->orderGoodModel->whereIn('id',json_decode($this->refundInfo->good_ids,true))->update(['refund_status' => OrderCode::FINISH_REFUND]),
|
||||
};
|
||||
|
||||
}catch (Exception $e) {
|
||||
$this->log->error(__CLASS__.':Function:manageGoodOrder:'.$e->getMessage().':orderId:'.$this->orderInfo->id);
|
||||
throw new ErrException('Function:RefundFinish:'.$e->getMessage().':orderId:'.$this->orderInfo->id);
|
||||
|
||||
Reference in New Issue
Block a user