|
|
@@ -10,6 +10,8 @@ use App\Models\Manager\WashConfig\ViolationProductCompany as ViolationProductCom
|
|
|
use App\Models\Manager\Personnel\Employee as EmployeeModel;
|
|
|
use App\Models\Manager\WashConfig\CompanyCategory as CompanyCategoryModel;
|
|
|
use App\Models\Manager\Citys as CitysModel;
|
|
|
+use App\Models\Manager\WashConfig\ViolationCompanyMember as ViolationCompanyMemberModel;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
/**
|
|
|
* 数据清洗-违规店铺(公司)配置
|
|
|
@@ -319,8 +321,13 @@ class ViolationCompany extends Controller
|
|
|
* @date 2025-12-03
|
|
|
*
|
|
|
*/
|
|
|
- public function delete(Request $request, ViolationCompanyModel $ViolationCompanyModel, LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel, ViolationProductCompanyModel $ViolationProductCompanyModel)
|
|
|
- {
|
|
|
+ public function delete(
|
|
|
+ Request $request,
|
|
|
+ ViolationCompanyModel $ViolationCompanyModel,
|
|
|
+ LowPriceGoodsCompanyModel $LowPriceGoodsCompanyModel,
|
|
|
+ ViolationProductCompanyModel $ViolationProductCompanyModel,
|
|
|
+ ViolationCompanyMemberModel $ViolationCompanyMemberModel
|
|
|
+ ) {
|
|
|
// 验证参数
|
|
|
$request->scene('delete')->validate();
|
|
|
$admin_company_id = request('admin_company_id', '0');
|
|
|
@@ -353,15 +360,25 @@ class ViolationCompany extends Controller
|
|
|
// 执行删除
|
|
|
$ViolationCompany = $ViolationCompanyModel->where($where)->first();
|
|
|
if (!$ViolationCompany) return json_send(['code' => 'error', 'msg' => '记录不存在']);
|
|
|
- $result = $ViolationCompany->delete();
|
|
|
- // 提示删除失败
|
|
|
- if (!$result) return json_send(['code' => 'error', 'msg' => '删除失败']);
|
|
|
+ DB::beginTransaction();
|
|
|
+ try {
|
|
|
+ //删除绑定关系
|
|
|
+ if ($ViolationCompany->employee_ids != '') {
|
|
|
+ $ViolationCompanyMemberModel->where(['company_logid' => $id])->delete();
|
|
|
+ }
|
|
|
+ $ViolationCompany->delete();
|
|
|
+ DB::commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ DB::rollback();
|
|
|
+ // 提示删除失败
|
|
|
+ return json_send(['code' => 'error', 'msg' => '删除失败']);
|
|
|
+ }
|
|
|
// 记录行为
|
|
|
$admin_id = request('access_token.uid', 0); //用户ID
|
|
|
$is_admin = request('access_token.is_admin'); //是否管理员操作 0=是1=否
|
|
|
$table_name = $ViolationCompanyModel->getTable();
|
|
|
$notes_type = 3; //操作类型,1添加,2修改,3=删除
|
|
|
- $this->addAdminHistory('清洗配置-公司管理',$company_id, $admin_id, $is_admin, $table_name, $notes_type, $ViolationCompany->toarray(), [], '删除了公司' . $ViolationCompany->company_name . '信息');
|
|
|
+ $this->addAdminHistory('清洗配置-公司管理', $company_id, $admin_id, $is_admin, $table_name, $notes_type, $ViolationCompany->toarray(), [], '删除了公司' . $ViolationCompany->company_name . '信息');
|
|
|
// 告知结果
|
|
|
return json_send(['code' => 'success', 'msg' => '删除成功']);
|
|
|
}
|