|
|
|
@ -307,6 +307,20 @@ class ProductController extends AdminController |
|
|
|
$form->status = ProductStatus::UNAUDITED; |
|
|
|
} else if ($form->isEditing() && in_array($form->model()->status, $user_status) && in_array($form->status, $user_status)) { //如果原来是下架或上架状态才允许修改
|
|
|
|
$form->status = $form->status == ProductStatus::ON_SALE ? ProductStatus::ON_SALE : ProductStatus::SOLD_OUT; |
|
|
|
|
|
|
|
//因extends是数组,具有一定的特殊性,不能直接用$form->saved方法中的wasChanged判断是否修改,所以只能在这里做特殊处理
|
|
|
|
if (!is_null($form->extends)) { |
|
|
|
$old_extends = array_filter($form->model()->extends, fn($v, $k) => str_contains($k, 'field_' . $form->model()->type) && !empty($v), ARRAY_FILTER_USE_BOTH); |
|
|
|
$new_extends = array_filter($form->extends, fn($v, $k) => str_contains($k, 'field_' . $form->model()->type) && !empty($v), ARRAY_FILTER_USE_BOTH); |
|
|
|
|
|
|
|
$old = $new = []; |
|
|
|
array_walk_recursive($old_extends, function($v) use (&$old) {if ($v !== null) $old[] = $v;}); |
|
|
|
array_walk_recursive($new_extends, function($v) use (&$new) {if ($v !== null) $new[] = $v;}); |
|
|
|
|
|
|
|
if (array_diff($old, $new)) { |
|
|
|
$form->status = ProductStatus::UNAUDITED; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
$form->deleteInput('status'); |
|
|
|
} |
|
|
|
@ -317,7 +331,7 @@ class ProductController extends AdminController |
|
|
|
DB::beginTransaction(); |
|
|
|
try { |
|
|
|
//如果修改标题、价格、产品图片、旅游须知、产品详情,状态将变为未审核
|
|
|
|
if ($form->model()->wasChanged(['title', 'price', 'original_price', 'pictures', 'know', 'content', 'extends', 'spec'])) { |
|
|
|
if ($form->model()->wasChanged(['title', 'price', 'original_price', 'pictures', 'know', 'content', 'spec'])) { |
|
|
|
$form->model()->update(['status' => ProductStatus::UNAUDITED]); |
|
|
|
|
|
|
|
//下架所有代理商产品,未审核的产品,不能同步信息到代理商产品
|
|
|
|
|