mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 06:46:08 -06:00
commit
99f2ddd5af
@ -1106,4 +1106,34 @@ class AdvsController extends PublicController
|
|||||||
}
|
}
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
public function stockControl(Request $request, AdvRepositoryInterface $advRepository)
|
||||||
|
{
|
||||||
|
$quantity = $request->quantity;
|
||||||
|
$id = $request->id;
|
||||||
|
$type = $request->type;
|
||||||
|
if ($request->dataType === 'ad-configuration') {
|
||||||
|
$optionConf = new OptionConfigurationModel();
|
||||||
|
$adv = $optionConf->newQuery()->find($id);
|
||||||
|
$status = $adv->stockControl($id, $quantity);
|
||||||
|
} else {
|
||||||
|
$advmodel = new AdvModel();
|
||||||
|
$adv = $advmodel->getAdv($id);
|
||||||
|
$status = $advmodel->stockControl($id, $quantity);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = array();
|
||||||
|
if ($status == 1) {
|
||||||
|
$response['newQuantity'] = $advRepository->getQuantity($quantity, $type, $adv);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$response['newQuantity'] = $adv->stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response['newPrice'] = $adv->price * $response['newQuantity'];
|
||||||
|
|
||||||
|
$response['newPrice'] = app(Currency::class)->format($response['newPrice'], strtoupper($adv->currency));
|
||||||
|
$response['status'] = $status;
|
||||||
|
$response['maxQuantity'] = $adv->stock;
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user