Explorar el Código

解决系统日志中的盘点批量跳过报错问题,以及采购小程序接口调整

hu hao hace 5 años
padre
commit
381eda28da

+ 4 - 3
app/Http/Controllers/CommodityController.php

@@ -172,14 +172,15 @@ class CommodityController extends Controller
     public function apiGetCommodityByBarcode(Request $request)
     {
         $barcode=$request->input('barcode');
-        $name = '';
+//        $name = '';
+        $commodity = '';
         if($barcode){
             $commodity=Commodity::query()->whereHas('barcodes', function (Builder $query)use($barcode){
                 $query->where('code',$barcode);
             })->first();
-            if($commodity&&$commodity['name']) $name=$commodity['name'];
+//            if($commodity&&$commodity['name']) $name=$commodity['name'];
         }
-        return ['success'=>'true','name'=>$name];
+        return ['success'=>'true','commodity'=>$commodity];
     }
 
     public function syncWMS(Request $request){

+ 1 - 1
app/Http/Controllers/InventoryAccountController.php

@@ -393,7 +393,7 @@ class InventoryAccountController extends Controller
         }
         $marks = [];
         foreach ($checkData as $inventoryMission) {
-            array_push($marks, $inventoryMission['mark']);
+            if (isset($inventoryMission['mark']))array_push($marks,$inventoryMission['mark']);
         }
         if (in_array('确认差异', $marks) || in_array('跳过', $marks) || in_array('无差异', $marks) || in_array('已复盘无差异', $marks)) return ['success' => false, 'data' => '传入勾选盘点记录存在不可操作项!'];
         /** @var InventoryAccountService $inventoryService */

+ 26 - 14
app/Http/Controllers/api/thirdPart/weixin/ProcurementController.php

@@ -29,21 +29,33 @@ class ProcurementController extends Controller
         $supplierService=app(SupplierService::class);
         $supplier_ids=$supplierService->screenSupplierIds();
         $status=$request->input('status');//0:待报价,2:待接单
-        $procurements=Procurement::query()
-            ->withCount('procurementQuotations')
-            ->with('ownerMaterial.material')
-            ->where('status',$status)
-            ->whereHas("ownerMaterial",function (Builder $query)use($supplier_ids){
-                $query->whereHas("material",function (Builder $query)use($supplier_ids){
-                    $query->whereHas("supplier",function (Builder $query)use($supplier_ids){
-                        $query->whereIn('id',$supplier_ids);
-                    });
-                });
-            })
-            ->get();
-
+        switch ($status){
+            case 0:
+                $procurements=Procurement::query()
+                    ->withCount('procurementQuotations')
+                    ->with('ownerMaterial.material')
+                    ->where('status',$status)
+                    ->whereHas("ownerMaterial",function (Builder $query)use($supplier_ids){
+                        $query->whereHas("material",function (Builder $query)use($supplier_ids){
+                            $query->whereHas("supplier",function (Builder $query)use($supplier_ids){
+                                $query->whereIn('id',$supplier_ids);
+                            });
+                        });
+                    })
+                    ->get();
+                break;
+            case 2:
+                $procurements=Procurement::query()
+                    ->withCount('procurementQuotations')
+                    ->with('ownerMaterial.material')
+                    ->where('status',$status)
+                    ->whereIn('supplier_id',$supplier_ids)
+                    ->get();
+                break;
+        }
+        if (!isset($procurements))return $this->error('未查到相应单据');
         foreach ($procurements as $key=>$procurement){
-            if ($procurement->procurement_quotations_count>0 && !$user->isSuperAdmin()){
+            if ($status==0 && $procurement->procurement_quotations_count>0 && !$user->isSuperAdmin()){
                 foreach ($procurement->procurementQuotations as $procurementQuotation){
                     if (in_array($procurementQuotation->supplier_id,$supplier_ids))unset($procurements[$key]);
                 }

+ 9 - 7
app/Services/InventoryAccountService.php

@@ -592,13 +592,15 @@ class InventoryAccountService
             array_push($inventoryAccountMissions,$inventoryAccountMission);
         }
         app('LogService')->log(__METHOD__,"批量跳过或确认差异",json_encode($checkData));
-        $inventoryAccount=InventoryAccount::query()->find($inventoryAccountId);
-        $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
-        $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
-        $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
-        $inventoryAccount->ignored=$inventoryAccount->getIgnoredAmount();
-        $inventoryAccount->update();
-        Controller::logS(__METHOD__,'批量跳过或确认差异修改盘点任务信息'.__FUNCTION__,json_encode($inventoryAccountId));
+        if ($inventoryAccountId){
+            $inventoryAccount=InventoryAccount::query()->find($inventoryAccountId);
+            $inventoryAccount->processed=$inventoryAccount->getProcessedAmount();//已盘点数
+            $inventoryAccount->difference=$inventoryAccount->getDifferenceAmount();//盘点差异数
+            $inventoryAccount->returned=$inventoryAccount->getReturnedAmount(); //复盘归位数
+            $inventoryAccount->ignored=$inventoryAccount->getIgnoredAmount();
+            $inventoryAccount->update();
+            Controller::logS(__METHOD__,'批量跳过或确认差异修改盘点任务信息'.__FUNCTION__,json_encode($inventoryAccountId));
+        }
         return $inventoryAccountMissions;
     }
     public function searchCommodityByBarcode($barcode,$owner_code){

+ 32 - 3
resources/views/rejected/create.blade.php

@@ -430,7 +430,9 @@
                         @foreach($qualityLabels as $qualityLabel)
                     {id:'{{$qualityLabel->id}}',name:'{{$qualityLabel->name}}'},
                     @endforeach
-                ]
+                ],
+                commodityOwnerId:'',
+
             },
             mounted:function () {
                 let _this=this;
@@ -483,8 +485,10 @@
                     axios.post(url,{barcode:barcode}).then(function (response) {
                         _this.cleanError();
                         if(response.data.success==='true'){
-                            if(response.data.name){
-                                _this.itemInputting.name_goods=response.data.name;
+                            if(response.data.commodity){
+                                // _this.itemInputting.name_goods=response.data.name;
+                                 _this.itemInputting.name_goods=response.data.commodity.name;
+                                 _this.commodityOwnerId=response.data.commodity.owner_id;
                             }
                         }else{
                             tempTip.setDuration(3000);
@@ -685,6 +689,9 @@
                     let _this=this;
                     let url='{{url('apiLocal/rejectedBillItem/store')}}';
                     _this.itemInputting.id_rejected_bill=_this.status.editingBill.id;
+                    // if (_this.items.length<1 && _this.commodityOwnerId!==_this.billInputting.id_owner){
+                    //
+                    // }
                     axios.post(url,_this.itemInputting).then(function (response) {
                         _this.cleanError();
                         if(response.data.success==='true'){
@@ -710,6 +717,28 @@
                         alert('连接错误:'+response)
                     });
                 },
+                isChangeOwner(){
+                    window.tempTip.confirm('当前退货记录货主名与录入商品的货主不匹配' + this.procurement_type[type] + ' ' + code, () => {
+                        window.axios.get("{{url('')}}/" + id)
+                            // .then(res => {
+                        //         if (res.data.success) {
+                        //             this.procurements.forEach(function (procurement) {
+                        //                 if (procurement.id === res.data.data.id) {
+                        //                     procurement.status = res.data.data.status;
+                        //                     window.tempTip.setDuration(2000);
+                        //                     window.tempTip.showSuccess("已成功取消该条采购申请");
+                        //                 }
+                        //             })
+                        //         } else {
+                        //             tempTip.setDuration(3000);
+                        //             tempTip.show(res.data.message);
+                        //         }
+                        //     }).catch(err => {
+                        //     window.tempTip.setDuration(3000);
+                        //     window.tempTip.show("网络错误:" + err);
+                        // });
+                    });
+                },
                 endAndPackCommitEdit:function () {
                     let _this=this;
                     if(_this.items.length===0){