|
@@ -50,6 +50,41 @@ class Company extends Controller
|
|
|
return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
|
|
return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 全部
|
|
|
|
|
+ * @author 唐远望
|
|
|
|
|
+ * @version 1.0
|
|
|
|
|
+ * @date 2026-02-03
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
+ public function all(Request $request, CompanyModel $CompanyModel)
|
|
|
|
|
+ {
|
|
|
|
|
+ $request->scene('all')->validate();
|
|
|
|
|
+ // 查询条件
|
|
|
|
|
+ $map = [];
|
|
|
|
|
+ $status = request('status', '');
|
|
|
|
|
+ $start_time = request('start_time', '');
|
|
|
|
|
+ $end_time = request('end_time', '');
|
|
|
|
|
+ $company_name = request('company_name', '');
|
|
|
|
|
+ // 时间条件
|
|
|
|
|
+ if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
|
|
|
|
|
+ if ($end_time) $map[] = ['insert_time', '<=', strtotime($end_time)];
|
|
|
|
|
+ // 其他条件
|
|
|
|
|
+ if (is_numeric($status)) $map[] = ['status', '=', $status];
|
|
|
|
|
+ if ($company_name) $map[] = ['company_name', 'like', "%$company_name%"];
|
|
|
|
|
+ // 查询数据
|
|
|
|
|
+ $result = $CompanyModel->query()
|
|
|
|
|
+ ->where($map)
|
|
|
|
|
+ ->orderByDesc('id')
|
|
|
|
|
+ ->get();
|
|
|
|
|
+ // 分配数据
|
|
|
|
|
+ if (!$result) return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => []]);
|
|
|
|
|
+ // 加载模板
|
|
|
|
|
+ return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $result]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 详情
|
|
* 详情
|
|
|
* @author 唐远望
|
|
* @author 唐远望
|
|
@@ -65,8 +100,6 @@ class Company extends Controller
|
|
|
// 权限判断
|
|
// 权限判断
|
|
|
$data = $CompanyModel->where($map)->first();
|
|
$data = $CompanyModel->where($map)->first();
|
|
|
if (!$data) return json_send(['code' => 'error', 'msg' => '记录不存在']);
|
|
if (!$data) return json_send(['code' => 'error', 'msg' => '记录不存在']);
|
|
|
-
|
|
|
|
|
- $data->platform = isset($data->platform) ? explode(',', $data->platform) : '';
|
|
|
|
|
// 加载模板
|
|
// 加载模板
|
|
|
return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
|
|
return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
|
|
|
}
|
|
}
|
|
@@ -82,19 +115,8 @@ class Company extends Controller
|
|
|
{
|
|
{
|
|
|
$request->scene('add')->validate();
|
|
$request->scene('add')->validate();
|
|
|
$all_data = request()->all();
|
|
$all_data = request()->all();
|
|
|
- //采集信息配置
|
|
|
|
|
- $minimum_order_quantity = request('minimum_order_quantity', 1);
|
|
|
|
|
- $sampling_cycle = request('sampling_cycle', '0');
|
|
|
|
|
- $sampling_start_time = request('sampling_start_time', '');
|
|
|
|
|
- $sampling_end_time = request('sampling_end_time', '');
|
|
|
|
|
- $all_data['sampling_cycle'] = $sampling_cycle;
|
|
|
|
|
- $all_data['sampling_start_time'] = $sampling_start_time ? strtotime($sampling_start_time . '00:00:00') : '0';
|
|
|
|
|
- $all_data['sampling_end_time'] = $sampling_end_time ? strtotime($sampling_end_time . '23:59:59') : '0';
|
|
|
|
|
- $all_data['minimum_order_quantity'] = $minimum_order_quantity;
|
|
|
|
|
- $allow_sampling_time = Carbon::tomorrow()->startOfDay()->getTimestamp(); // 明天的开始时间(允许开始采集时间校验)
|
|
|
|
|
- if ($all_data['sampling_start_time'] && $all_data['sampling_start_time'] < $allow_sampling_time) return json_send(['code' => 'error', 'msg' => '采集最早开始时间为明天']);
|
|
|
|
|
//查询是否存在
|
|
//查询是否存在
|
|
|
- $map = ['company_name' => $all_data['company_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
|
|
|
|
|
|
|
+ $map = ['social_credit_code' => $all_data['social_credit_code']];
|
|
|
$data = $CompanyModel->where($map)->first();
|
|
$data = $CompanyModel->where($map)->first();
|
|
|
if ($data) return json_send(['code' => 'error', 'msg' => '记录已存在']);
|
|
if ($data) return json_send(['code' => 'error', 'msg' => '记录已存在']);
|
|
|
// 写入数据表
|
|
// 写入数据表
|
|
@@ -125,17 +147,8 @@ class Company extends Controller
|
|
|
$id = request('id', 0);
|
|
$id = request('id', 0);
|
|
|
// 接收数据
|
|
// 接收数据
|
|
|
$all_data = request()->all();
|
|
$all_data = request()->all();
|
|
|
- //采集信息配置
|
|
|
|
|
- $minimum_order_quantity = request('minimum_order_quantity', 1);
|
|
|
|
|
- $sampling_cycle = request('sampling_cycle', '0');
|
|
|
|
|
- $sampling_start_time = request('sampling_start_time', '');
|
|
|
|
|
- $sampling_end_time = request('sampling_end_time', '');
|
|
|
|
|
- $all_data['sampling_cycle'] = $sampling_cycle;
|
|
|
|
|
- $all_data['sampling_start_time'] = $sampling_start_time ? strtotime($sampling_start_time . '00:00:00') : '0';
|
|
|
|
|
- $all_data['sampling_end_time'] = $sampling_end_time ? strtotime($sampling_end_time . '23:59:59') : '0';
|
|
|
|
|
- $all_data['minimum_order_quantity'] = $minimum_order_quantity;
|
|
|
|
|
//查询是否存在
|
|
//查询是否存在
|
|
|
- $map = ['company_name' => $all_data['company_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
|
|
|
|
|
|
|
+ $map = ['social_credit_code' => $all_data['social_credit_code']];
|
|
|
$data = $CompanyModel->where($map)->where('id', '!=', $id)->first();
|
|
$data = $CompanyModel->where($map)->where('id', '!=', $id)->first();
|
|
|
if ($data) return json_send(['code' => 'error', 'msg' => '记录已存在']);
|
|
if ($data) return json_send(['code' => 'error', 'msg' => '记录已存在']);
|
|
|
// 更新数据表
|
|
// 更新数据表
|
|
@@ -143,8 +156,6 @@ class Company extends Controller
|
|
|
$Company = $CompanyModel->where($where)->first();
|
|
$Company = $CompanyModel->where($where)->first();
|
|
|
if (!$Company) return json_send(['code' => 'error', 'msg' => '记录不存在']);
|
|
if (!$Company) return json_send(['code' => 'error', 'msg' => '记录不存在']);
|
|
|
$oldData = $Company->toarray();
|
|
$oldData = $Company->toarray();
|
|
|
- $allow_sampling_time = Carbon::tomorrow()->startOfDay()->getTimestamp(); // 明天的开始时间(允许开始采集时间校验)
|
|
|
|
|
- if ($all_data['sampling_start_time'] && $all_data['sampling_start_time'] < $allow_sampling_time) return json_send(['code' => 'error', 'msg' => '采集最早开始时间为明天']);
|
|
|
|
|
$result = $CompanyModel->editCompany_content($Company, $all_data);
|
|
$result = $CompanyModel->editCompany_content($Company, $all_data);
|
|
|
// 如果操作失败
|
|
// 如果操作失败
|
|
|
if (!$result) return json_send(['code' => 'error', 'msg' => '修改失败']);
|
|
if (!$result) return json_send(['code' => 'error', 'msg' => '修改失败']);
|