Files
hyperf_service/app/Service/Admin/Coupon/DispenseConfirmService.php
2025-02-26 18:01:02 +08:00

99 lines
2.2 KiB
PHP

<?php
/**
* This service file is part of item.
*
* @author ctexthuang
* @contact ctexthuang@qq.com
*/
declare(strict_types=1);
namespace App\Service\Admin\Coupon;
use App\Constants\Common\CouponCode;
use App\Exception\ErrException;
use App\Model\CouponDispenseLog;
use App\Model\Cycle;
use App\Model\Order;
use App\Model\OrderGood;
use App\Model\Site;
use App\Model\Sku;
use App\Model\User;
use App\Service\Admin\BaseService;
use App\Service\ServiceTrait\Admin\CouponDispenseTrait;
use Exception;
use Hyperf\Di\Annotation\Inject;
class DispenseConfirmService extends BaseService
{
use CouponDispenseTrait;
/**
* @var Order
*/
#[Inject]
protected Order $orderModel;
/**
* @var Sku
*/
#[Inject]
protected Sku $skuModel;
/**
* @var OrderGood
*/
#[Inject]
protected OrderGood $orderGoodModel;
/**
* @var Site
*/
#[Inject]
protected Site $siteModel;
/**
* @var Cycle
*/
#[Inject]
protected Cycle $cycleModel;
/**
* @var int
*/
private int $cycleId;
/**
* @var array
*/
private array $appointValue;
/**
* @var int
*/
private int $groupType;
/**
* @return array
* @throws Exception
*/
public function handle(): array
{
try {
$userIdList = match ($this->groupType = (int)$this->request->input('appoint_group',CouponCode::DISPENSE_APPOINT_GROUP_ALL_PEOPLE))
{
CouponCode::DISPENSE_APPOINT_GROUP_DESIGNATED_USERS => $this->handleDesignatedUsers(),
CouponCode::DISPENSE_APPOINT_GROUP_DESIGNATED_SITES => $this->handleDesignatedSites(),
CouponCode::DISPENSE_APPOINT_GROUP_DESIGNATED_GOODS => $this->handleDesignatedGoods(),
CouponCode::DISPENSE_APPOINT_GROUP_DESIGNATED_SITES_AND_GOODS => $this->handleDesignatedSitesAndGoods(),
default => throw new Exception('不需要渲染用户数据')
};
return $this->return->success('success',['list' => $userIdList]);
}catch (Exception $e) {
throw new ErrException($e->getMessage());
}
}
}