feat : coupon template

This commit is contained in:
2025-02-26 10:11:34 +08:00
parent af23f61991
commit d22eb0c076
3 changed files with 40 additions and 12 deletions

View File

@@ -116,12 +116,19 @@ class DispenseConfirmService extends BaseService
} }
} }
private function handleDesignatedUsers() /**
* @return void
*/
private function handleDesignatedUsers(): void
{ {
$this->res = explode(',',$this->request->input('appoint_value'));
} }
private function handleDesignatedSitesAndGoods() /**
* @return void
* @throws Exception
*/
private function handleDesignatedSitesAndGoods(): void
{ {
$this->getValueAndCheckDate(); $this->getValueAndCheckDate();
@@ -132,7 +139,11 @@ class DispenseConfirmService extends BaseService
$this->getUserData(); $this->getUserData();
} }
private function handleDesignatedSites() /**
* @return void
* @throws Exception
*/
private function handleDesignatedSites(): void
{ {
$this->getValueAndCheckDate(); $this->getValueAndCheckDate();
@@ -141,7 +152,11 @@ class DispenseConfirmService extends BaseService
$this->getUserData(); $this->getUserData();
} }
private function handleDesignatedGoods() /**
* @return void
* @throws Exception
*/
private function handleDesignatedGoods(): void
{ {
$this->getValueAndCheckDate(); $this->getValueAndCheckDate();

View File

@@ -48,7 +48,7 @@ class OptionalListService extends BaseService
$this->goodCache->cycleId = (int)$cycleId; $this->goodCache->cycleId = (int)$cycleId;
$siteInfo = $this->siteCache->getSiteInfo((int)$this->request->input('site_id')); $siteInfo = $this->siteCache->getSiteInfo((int)$this->request->input('site_id'));
if (empty($siteInfo) || empty($siteInfo['kitchen_id'])) return ['list' => []]; if (empty($siteInfo) || empty($siteInfo['kitchen_id'])) return $this->return->success('success', ['list' => []]);
$this->goodCache->kitchenId = $siteInfo['kitchen_id']; $this->goodCache->kitchenId = $siteInfo['kitchen_id'];
$data = $this->goodCache->getOptionalGoodList(); $data = $this->goodCache->getOptionalGoodList();

View File

@@ -24,10 +24,23 @@ trait CouponDispenseTrait
if (empty($cycleInfo)) throw new Exception('未找到该点餐周期'); if (empty($cycleInfo)) throw new Exception('未找到该点餐周期');
$this->cycleId = $cycleInfo->id; $this->cycleId = $cycleInfo->id;
if ($this->groupType == CouponCode::DISPENSE_APPOINT_GROUP_DESIGNATED_SITES_AND_GOODS) {
$appointValue = json_encode($this->request->input('appoint_value'));
$this->appointValue = [
'site' => explode(',', $appointValue['site']),
'sku' => explode(',', $appointValue['goods'])
];
}
$this->appointValue = explode(',', $this->request->input('appoint_value')); $this->appointValue = explode(',', $this->request->input('appoint_value'));
unset($cycleInfo); unset($cycleInfo);
} }
protected function getSiteAndGoodsValueAndCheckDate()
{
}
/** /**
* @return void * @return void
* @throws Exception * @throws Exception
@@ -51,10 +64,10 @@ trait CouponDispenseTrait
} }
/** /**
* @return array * @return void
* @throws Exception * @throws Exception
*/ */
protected function getUserData(): array protected function getUserData(): void
{ {
$userIds = []; $userIds = [];
@@ -95,16 +108,16 @@ trait CouponDispenseTrait
case CouponCode::DISPENSE_APPOINT_GROUP_DESIGNATED_SITES_AND_GOODS: case CouponCode::DISPENSE_APPOINT_GROUP_DESIGNATED_SITES_AND_GOODS:
$orderIds = $this->orderModel $orderIds = $this->orderModel
->where('cycle_id',$this->cycleId) ->where('cycle_id',$this->cycleId)
->whereIn('site_id',$this->appointValue) ->whereIn('site_id',$this->appointValue['site'])
->where('status',OrderCode::FINISH) ->where('status',OrderCode::FINISH)
->pluck('user_id','order_id') ->pluck('user_id','order_id')
->toArray(); ->toArray();
if (empty($orderIds)) throw new Exception('未找到该周期的订单'); if (empty($orderIds)) throw new Exception('未找到该周期该地点的订单');
$skuOrderIds = $this->orderGoodModel $skuOrderIds = $this->orderGoodModel
->whereIn('order_id',array_keys($orderIds)) ->whereIn('order_id',array_keys($orderIds))
->whereIn('sku_id',$this->appointValue) ->whereIn('sku_id',$this->appointValue['sku'])
->pluck('order_id') ->pluck('order_id')
->toArray(); ->toArray();
$skuOrderIds = array_unique($skuOrderIds); $skuOrderIds = array_unique($skuOrderIds);
@@ -115,7 +128,7 @@ trait CouponDispenseTrait
break; break;
} }
return $userIds; $this->res = $userIds;
} }
/** /**