|
|
@@ -4,10 +4,12 @@ namespace SixShop\LimitPurchase\Controller\Admin;
|
|
|
|
|
|
|
|
|
use SixShop\Core\Request;
|
|
|
+use SixShop\LimitPurchase\Entity\GoodsLimitPurchaseRuleEntity;
|
|
|
use SixShop\LimitPurchase\Entity\LimitPurchaseRuleEntity;
|
|
|
use think\Response;
|
|
|
use function SixShop\Core\page_response;
|
|
|
use function SixShop\Core\success_response;
|
|
|
+use function SixShop\Core\throw_logic_exception;
|
|
|
|
|
|
class RuleController
|
|
|
{
|
|
|
@@ -44,8 +46,11 @@ class RuleController
|
|
|
return success_response($limitPurchaseRuleEntity->withEvent(true)->update(data:$data));
|
|
|
}
|
|
|
|
|
|
- public function delete(int $id, LimitPurchaseRuleEntity $limitPurchaseRuleEntity)
|
|
|
+ public function delete(int $id, LimitPurchaseRuleEntity $limitPurchaseRuleEntity, GoodsLimitPurchaseRuleEntity $goodsLimitPurchaseRuleEntity)
|
|
|
{
|
|
|
+ if(0 < $goodsLimitPurchaseRuleEntity->where('rule_id', $id)->count()) {
|
|
|
+ throw_logic_exception('此规则下有商品正在使用,请先解除关联');
|
|
|
+ }
|
|
|
return success_response($limitPurchaseRuleEntity::destroy($id));
|
|
|
}
|
|
|
}
|