diff --git a/admin/src/views/product/edit.vue b/admin/src/views/product/edit.vue index 8c4e9d17..f4554c43 100644 --- a/admin/src/views/product/edit.vue +++ b/admin/src/views/product/edit.vue @@ -153,7 +153,6 @@ const queryUser = async (query: string) => { } const selectedUser = (value: any) => { - console.log(value) queryLand(value) } diff --git a/app/adminapi/logic/land/ProductLogic.php b/app/adminapi/logic/land/ProductLogic.php index bec1ea07..9503cd01 100644 --- a/app/adminapi/logic/land/ProductLogic.php +++ b/app/adminapi/logic/land/ProductLogic.php @@ -38,12 +38,21 @@ class ProductLogic extends BaseLogic */ public static function add(array $params): bool { + $root = (request()->adminInfo)['root']; $userId = (request()->adminInfo)['user_id']; $status = 1; + if ($root && !empty($params['user_id'])) { + $userId = $params['user_id']; + } if (!empty($params['land_id'])) { - $userId = Db::name('land')->where('id', $params['land_id'])->value('user_id'); + $res = Db::name('land_product')->where('land_id', $params['land_id'])->find(); + if ($res) { + self::setError('该土地已绑定产品'); + return false; + } $status = 2; } + Db::startTrans(); try { $product = Product::create([ @@ -79,10 +88,18 @@ class ProductLogic extends BaseLogic */ public static function edit(array $params): bool { + $root = (request()->adminInfo)['root']; $userId = (request()->adminInfo)['user_id']; $status = 1; + if ($root && !empty($params['user_id'])) { + $userId = $params['user_id']; + } if (!empty($params['land_id'])) { - $userId = Db::name('land')->where('id', $params['land_id'])->value('user_id'); + $res = Db::name('land_product')->where('land_id', $params['land_id'])->where('product_id', '<>' ,$params['id'])->find(); + if ($res) { + self::setError('该土地已绑定产品'); + return false; + } $status = 2; } Db::startTrans();