更新产品绑定
This commit is contained in:
parent
671db7e8f0
commit
6f3314f92c
|
@ -153,7 +153,6 @@ const queryUser = async (query: string) => {
|
|||
}
|
||||
|
||||
const selectedUser = (value: any) => {
|
||||
console.log(value)
|
||||
queryLand(value)
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue