feat : auto coupon

This commit is contained in:
2025-02-26 18:01:02 +08:00
parent 14ca3b6377
commit c8db3e170d
10 changed files with 605 additions and 86 deletions

View File

@@ -52,29 +52,12 @@ class DispenseConfirmService extends BaseService
#[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
*/
@@ -97,11 +80,7 @@ class DispenseConfirmService extends BaseService
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))
$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(),
@@ -110,59 +89,11 @@ class DispenseConfirmService extends BaseService
default => throw new Exception('不需要渲染用户数据')
};
return $this->return->success('success',['list' => $this->res]);
return $this->return->success('success',['list' => $userIdList]);
}catch (Exception $e) {
throw new ErrException($e->getMessage());
}
}
/**
* @return void
*/
private function handleDesignatedUsers(): void
{
$this->res = explode(',',$this->request->input('appoint_value'));
}
/**
* @return void
* @throws Exception
*/
private function handleDesignatedSitesAndGoods(): void
{
$this->getValueAndCheckDate();
$this->checkSite();
$this->checkSku();
$this->getUserData();
}
/**
* @return void
* @throws Exception
*/
private function handleDesignatedSites(): void
{
$this->getValueAndCheckDate();
$this->checkSite();
$this->getUserData();
}
/**
* @return void
* @throws Exception
*/
private function handleDesignatedGoods(): void
{
$this->getValueAndCheckDate();
$this->checkSku();
$this->getUserData();
}
}