feat : ide config
This commit is contained in:
@@ -9,6 +9,7 @@ use App\Constants\Common\OrderCode;
|
||||
use App\Lib\Log;
|
||||
use App\Model\Order;
|
||||
use App\Model\UserCoupon;
|
||||
use App\Service\ServiceTrait\Api\CouponTrait;
|
||||
use App\Service\ServiceTrait\Api\OrderTrait;
|
||||
use Exception;
|
||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||
@@ -28,6 +29,7 @@ class CancelOrderConsumer extends ConsumerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait,ConsumerDelayedMessageTrait;
|
||||
use OrderTrait;
|
||||
use CouponTrait;
|
||||
|
||||
/**
|
||||
* @var Type|string 消息类型
|
||||
@@ -103,27 +105,4 @@ class CancelOrderConsumer extends ConsumerMessage
|
||||
|
||||
return Result::ACK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $orderType
|
||||
* @param $orderInfo
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
private function rollbackCoupon($orderType,$orderInfo): void
|
||||
{
|
||||
if ($orderType != OrderCode::ORDER_TYPE_GOOD) return;
|
||||
|
||||
if ($orderInfo->coupon_id <= 0) return;
|
||||
|
||||
$couponInfo = $this->userCouponModel->where('coupon_id', $orderInfo->coupon_id)->where('user_id',$orderInfo->user_id)->first();
|
||||
|
||||
if (empty($couponInfo)) return;
|
||||
|
||||
$couponInfo->status = CouponCode::COUPON_STATUS_UNUSED;
|
||||
|
||||
if (date('Y-m-d H:i:s') > $couponInfo->validity_end_time) $couponInfo->status = CouponCode::COUPON_STATUS_EXPIRE;
|
||||
|
||||
if (!$couponInfo->save()) throw new Exception('CancelOrderConsumer:error:couponStatusUpdateError:'.json_encode($orderInfo->toArray()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user