|
|
@@ -1065,11 +1065,19 @@ class ProcessController extends Controller
|
|
|
$query->where('code',$str)->orWhere('name',$str);
|
|
|
})->first();
|
|
|
if (!$owner){
|
|
|
- $owner = Owner::query()->create([
|
|
|
- 'code' => $str,
|
|
|
- 'name' => $str
|
|
|
- ]);
|
|
|
- app('LogService')->log(__METHOD__,"二次加工单录入导入商品数据时添加货主".__FUNCTION__,json_encode($owner),Auth::user()['id']);
|
|
|
+ $owner=Owner::query()->whereNotNull("deleted_at")->where(function ($query)use($str){
|
|
|
+ $query->where('code',$str)->orWhere('name',$str);
|
|
|
+ })->first();
|
|
|
+ if (!$owner){
|
|
|
+ $owner = Owner::query()->create([
|
|
|
+ 'code' => $str,
|
|
|
+ 'name' => $str
|
|
|
+ ]);
|
|
|
+ Log::info("二次加工录入货主",["owner"=>$owner->toJson(),"user"=>Auth::id()]);
|
|
|
+ }else{
|
|
|
+ $owner->update(["deleted_at"=>null]);
|
|
|
+ Log::info("二次加工恢复货主",["owner"=>$owner->toJson(),"user"=>Auth::id()]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
$goods = Commodity::query()->with('barcodes')->where('owner_id',$owner->id)//->whereNull('owner_id') 保留,暂时不知为何限定货主为空
|