|
|
@@ -104,6 +104,8 @@ class Product extends Controller
|
|
|
$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 = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
|
|
|
$data = $ProductModel->where($map)->first();
|
|
|
@@ -154,6 +156,11 @@ class Product extends Controller
|
|
|
$Product = $ProductModel->where($where)->first();
|
|
|
if (!$Product) return json_send(['code' => 'error', 'msg' => '记录不存在']);
|
|
|
$oldData = $Product->toarray();
|
|
|
+ //如果修改采集周期,则校验采集时间是否在明天以后
|
|
|
+ if ($sampling_cycle != $Product->sampling_cycle) {
|
|
|
+ $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 = $ProductModel->editProduct_content($Product, $all_data);
|
|
|
// 如果操作失败
|
|
|
if (!$result) return json_send(['code' => 'error', 'msg' => '修改失败']);
|
|
|
@@ -185,9 +192,9 @@ class Product extends Controller
|
|
|
//获取商品启用数量
|
|
|
// $product_count = $ProductModel->where('status', 0)->count();
|
|
|
//判断是否超过限制
|
|
|
- // if ($product_count >= 50) {
|
|
|
- // return json_send(['code' => 'error', 'msg' => '启用数量超过限制,不能超过50条']);
|
|
|
- // }
|
|
|
+ if ($product_count >= 50) {
|
|
|
+ return json_send(['code' => 'error', 'msg' => '启用数量超过限制,不能超过50条']);
|
|
|
+ }
|
|
|
}
|
|
|
// 查询用户
|
|
|
$where = ['id' => $id];
|