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

153 lines
3.1 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 User
*/
#[Inject]
protected User $userModel;
/**
* @var CouponDispenseLog
*/
#[Inject]
protected CouponDispenseLog $couponDispenseLogModel;
/**
* @var Cycle
*/
#[Inject]
protected Cycle $cycleModel;
/**
* @var array
*/
private array $res;
/**
* @var int
*/
private int $cycleId;
/**
* @var array
*/
private array $appointValue;
/**
* @var int
*/
private int $groupType;
/**
* @return array
* @throws Exception
*/
public function handle(): array
{
try {
$this->res = [];
if (empty($this->request->input('appoint_value'))) throw new Exception('请选择指定值');
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' => $this->res]);
}catch (Exception $e) {
throw new ErrException($e->getMessage());
}
}
private function handleDesignatedUsers()
{
}
private function handleDesignatedSitesAndGoods()
{
$this->getValueAndCheckDate();
$this->checkSite();
$this->checkSku();
$this->getUserData();
}
private function handleDesignatedSites()
{
$this->getValueAndCheckDate();
$this->checkSite();
$this->getUserData();
}
private function handleDesignatedGoods()
{
$this->getValueAndCheckDate();
$this->checkSku();
$this->getUserData();
}
}