|
|
@@ -47,7 +47,12 @@ class StoreCheckingReceiveController extends Controller
|
|
|
if(!Gate::allows('入库管理-盘收一体-盘收-查看')){ return redirect(url('/')); }
|
|
|
/** @var StoreCheckingReceiveService $service */
|
|
|
$service = app('storeCheckingReceiveService');
|
|
|
- $storeCheckingReceive = $service->find($id);
|
|
|
+ $withs = ['owner','storeCheckingReceiveItems'=>function($query){
|
|
|
+ $query->with(['commodity'=>function($builder) {
|
|
|
+ $builder->with('barcodes');
|
|
|
+ }]);
|
|
|
+ }];
|
|
|
+ $storeCheckingReceive = $service->find($id,$withs);
|
|
|
$is_show = $request->is_show ?? true;
|
|
|
|
|
|
if ($storeCheckingReceive->owner ?? false){
|
|
|
@@ -68,7 +73,12 @@ class StoreCheckingReceiveController extends Controller
|
|
|
$goods = $request->goods ?? false;
|
|
|
if (!($goods["amount"] ?? false))$goods["amount"] = 1;
|
|
|
if (!$mission_id || !$goods)return ['success'=>false, 'data'=>'参数传递错误!'];
|
|
|
- $storeCheckingReceive = app('storeCheckingReceiveService')->find($mission_id);
|
|
|
+ $withs = ['owner','storeCheckingReceiveItems'=>function($query){
|
|
|
+ $query->with(['commodity'=>function($builder) {
|
|
|
+ $builder->with('barcodes');
|
|
|
+ }]);
|
|
|
+ }];
|
|
|
+ $storeCheckingReceive = app('storeCheckingReceiveService')->find($mission_id,$withs);
|
|
|
if (!$storeCheckingReceive)return ['success'=>false, 'data'=>'盘收任务不存在'];
|
|
|
if ($storeCheckingReceive->status == '已收货')return ['success'=>false, 'data'=>'盘收任务已结束'];
|
|
|
|
|
|
@@ -204,7 +214,12 @@ class StoreCheckingReceiveController extends Controller
|
|
|
public function export(Request $request){
|
|
|
if(!Gate::allows('入库管理-盘收一体-盘收-查看')){ return redirect(url('/')); }
|
|
|
$id = $request->mission_id ?? false;
|
|
|
- $storeCheckingReceive = app('storeCheckingReceiveService')->find($id);
|
|
|
+ $withs = ['owner','storeCheckingReceiveItems'=>function($query){
|
|
|
+ $query->with(['commodity'=>function($builder) {
|
|
|
+ $builder->with('barcodes');
|
|
|
+ }]);
|
|
|
+ }];
|
|
|
+ $storeCheckingReceive = app('storeCheckingReceiveService')->find($id,$withs);
|
|
|
|
|
|
if (!$storeCheckingReceive) new \Exception('盘收任务不存在');
|
|
|
|
|
|
@@ -263,7 +278,12 @@ class StoreCheckingReceiveController extends Controller
|
|
|
$id = $request->mission_id ?? false;
|
|
|
if (!$asn || !$id)return ['success'=>false, 'data'=>'传递参数错误'];
|
|
|
|
|
|
- $storeCheckingReceive = app('storeCheckingReceiveService')->find($id);
|
|
|
+ $withs = ['owner','storeCheckingReceiveItems'=>function($query){
|
|
|
+ $query->with(['commodity'=>function($builder) {
|
|
|
+ $builder->with('barcodes');
|
|
|
+ }]);
|
|
|
+ }];
|
|
|
+ $storeCheckingReceive = app('storeCheckingReceiveService')->find($id,$withs);
|
|
|
if (!$storeCheckingReceive) return ['success'=>false, 'data'=>'未找到此盘点任务!'];
|
|
|
if ($storeCheckingReceive->status == '已收货')return ['success'=>false, 'data'=>'盘收任务已结束'];
|
|
|
|
|
|
@@ -372,8 +392,34 @@ class StoreCheckingReceiveController extends Controller
|
|
|
if (!$id || !$counted_amount)return ['success'=>false, 'data'=>'参数传递错误!'];
|
|
|
$item = app('storeCheckingReceiveItemService')->find($id);
|
|
|
if (!$item)return ['success'=>false, 'data'=>'被盘项不存在'];
|
|
|
- app('storeCheckingReceiveItemService')->updateFind($item,["counted_amount"=>$counted_amount]);
|
|
|
+ $params = ["counted_amount"=>$counted_amount];
|
|
|
+ if ($item->imported_amount)$params["imported_diff_amount"] = (int)$counted_amount - (int)$item->imported_amount;
|
|
|
+ if ($item->asn_amount)$params["asn_diff_amount"] = (int)$counted_amount - (int)$item->asn_diff_amount;
|
|
|
+ //修改差异状态
|
|
|
+ if ($item->imported_amount || $item->asn_amount){
|
|
|
+ $withs = ['storeCheckingReceiveItems'];
|
|
|
+ $storeCheckingReceive = app('storeCheckingReceiveService')->find($id,$withs);
|
|
|
+ $this->updateDiffStatus($storeCheckingReceive);
|
|
|
+ }
|
|
|
+ app('storeCheckingReceiveItemService')->updateFind($item,$params);
|
|
|
LogService::log(__METHOD__,"盘点修改实盘数",'item:'.json_encode($item)."update:",$counted_amount);
|
|
|
return ['success'=>true];
|
|
|
}
|
|
|
+
|
|
|
+ //修改差异状态
|
|
|
+ private function updateDiffStatus(StoreCheckingReceive $scr){
|
|
|
+ $items = $scr->storeCheckingReceiveItems ?? [];
|
|
|
+ $is_receive_diff = "否";
|
|
|
+ $is_asn_diff = "否";
|
|
|
+ foreach ($items as $item){
|
|
|
+ if ($item->imported_diff_amount)$is_receive_diff = "是";
|
|
|
+ if ($item->asn_diff_amount)$is_asn_diff = "是";
|
|
|
+ }
|
|
|
+ if (($scr->is_receive_diff != $is_receive_diff) || ($scr->is_asn_diff != $is_asn_diff)){
|
|
|
+ $scr->update([
|
|
|
+ "is_receive_diff" => $is_receive_diff,
|
|
|
+ "is_asn_diff" => $is_asn_diff
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|